Commit 21063854 authored by 赵啸非's avatar 赵啸非

更新资源部署

parent 7e6da6ac
......@@ -10,6 +10,10 @@
<Field :span="20" label="上传文件"><fileUpload v-model="form.filePath" prePath="/file/uploadfile"/></Field>
<!--
<Field :span="20" label="默认选择" prop="imageResolution" v-model="form.selected" :enumData="dict.selected" type="radio" placeholder="默认选择"/>
-->
<Field :span="20" label="版本号" prop="version" v-model="form.version" placeholder="请输入版本号"/>
......
......@@ -72,6 +72,31 @@ export default {
});
},
handleSwitch(row){
if(row.selected==1){
this.$post("/device/module/distribute/selected", {id:row.id,selected:0})
.then(res => {
if(res.code==1){
row.selected=0;
}
})
.catch(error => {
this.$message.error(error.message);
})
}else{
this.$post("/device/module/distribute/selected", {id:row.id,selected:1})
.then(res => {
if(res.code==1){
row.selected=1;
}
})
.catch(error => {
this.$message.error(error.message);
})
}
this.getData();
},
distribute(row) {
this.$post("/device/module/distribute/active", row)
.then((res) => {
......@@ -114,7 +139,26 @@ export default {
},
{ label: "版本号", align: "center", prop: "version" },
{
label: "是否默认选择",
align: "center",
prop: "selected",
formatter: row => {
return (
<el-switch
value={row.selected+""}
active-color="#13ce66"
inactive-color="#ff4949"
active-value='1'
inactive-value='0'
onChange={() => {
this.handleSwitch(row);
}}
>
</el-switch>
);
}
},
{
label: "是否部署",
align: "center",
......
......@@ -10,14 +10,32 @@
/** 表单弹出框模式需引入 */
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table";
import session from "@/assets/utils/session";
export default {
name: "ProductList",
components: {
drawerShow,
},
mixins: [table],
created() {},
created() { const siteid = session.getSession("siteid");
this.query["siteId"]=siteid?siteid:1;
},
methods: {
cloneAppBySite(row) {
this.$post("/device/module/distribute/cloneAppBySite", {
sourceSiteId: 1,
targetSiteId: session.getSession("siteid"),
})
.then((res) => {
if (res.code == 1) {
this.$message.success("复制资源应用成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
/** 重写新增方法 */
toAdd(row) {
this.$refs.drawerform.add(row);
......
......@@ -66,6 +66,4 @@ ALTER TABLE mortals_xhx_product_version ADD COLUMN `siteName` varchar(256) de
-- ----------------------------
2023-08-21
-- ----------------------------
ALTER TABLE mortals_xhx_product ADD COLUMN `siteId` bigint(20) COMMENT '站点Id,来源基础服务平台';
ALTER TABLE mortals_xhx_product ADD COLUMN `siteCode` varchar(256) default '' COMMENT '站点编号,来源基础服务平台';
ALTER TABLE mortals_xhx_product ADD COLUMN `siteName` varchar(256) default '' COMMENT '站点名称';
ALTER TABLE mortals_xhx_device_module_distribute ADD COLUMN `selected` tinyint(2) NOT NULL default '0' COMMENT '是否默认选择分辨率(0.否,1.是)';
......@@ -7,7 +7,7 @@ import lombok.Data;
* 设备前端模块部署实体对象
*
* @author zxfei
* @date 2023-08-18
* @date 2023-08-21
*/
@Data
public class DeviceModuleDistributeEntity extends DeviceModuleDistributeVo {
......@@ -66,6 +66,11 @@ public class DeviceModuleDistributeEntity extends DeviceModuleDistributeVo {
* 站点名称
*/
private String siteName;
/**
* 是否默认选择分辨率(0.否,1.是)
*/
@Excel(name = "是否默认选择分辨率", readConverterExp = "0=否,1=是")
private Integer selected;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -83,7 +88,7 @@ public class DeviceModuleDistributeEntity extends DeviceModuleDistributeVo {
}
public void initAttrValue(){
this.productId = null;
this.productId = 0L;
this.productCode = "";
this.productName = "";
this.imageResolution = "";
......@@ -95,5 +100,6 @@ public class DeviceModuleDistributeEntity extends DeviceModuleDistributeVo {
this.siteId = 0L;
this.siteCode = "";
this.siteName = "";
this.selected = 0;
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import java.util.List;
* 设备前端模块部署查询对象
*
* @author zxfei
* @date 2023-08-18
* @date 2023-08-21
*/
public class DeviceModuleDistributeQuery extends DeviceModuleDistributeEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -140,6 +140,21 @@ public class DeviceModuleDistributeQuery extends DeviceModuleDistributeEntity {
/** 站点名称排除列表 */
private List <String> siteNameNotList;
/** 开始 是否默认选择分辨率(0.否,1.是) */
private Integer selectedStart;
/** 结束 是否默认选择分辨率(0.否,1.是) */
private Integer selectedEnd;
/** 增加 是否默认选择分辨率(0.否,1.是) */
private Integer selectedIncrement;
/** 是否默认选择分辨率(0.否,1.是)列表 */
private List <Integer> selectedList;
/** 是否默认选择分辨率(0.否,1.是)排除列表 */
private List <Integer> selectedNotList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<DeviceModuleDistributeQuery> orConditionList;
......@@ -905,6 +920,87 @@ public class DeviceModuleDistributeQuery extends DeviceModuleDistributeEntity {
this.siteNameNotList = siteNameNotList;
}
/**
* 获取 开始 是否默认选择分辨率(0.否,1.是)
* @return selectedStart
*/
public Integer getSelectedStart(){
return this.selectedStart;
}
/**
* 设置 开始 是否默认选择分辨率(0.否,1.是)
* @param selectedStart
*/
public void setSelectedStart(Integer selectedStart){
this.selectedStart = selectedStart;
}
/**
* 获取 结束 是否默认选择分辨率(0.否,1.是)
* @return $selectedEnd
*/
public Integer getSelectedEnd(){
return this.selectedEnd;
}
/**
* 设置 结束 是否默认选择分辨率(0.否,1.是)
* @param selectedEnd
*/
public void setSelectedEnd(Integer selectedEnd){
this.selectedEnd = selectedEnd;
}
/**
* 获取 增加 是否默认选择分辨率(0.否,1.是)
* @return selectedIncrement
*/
public Integer getSelectedIncrement(){
return this.selectedIncrement;
}
/**
* 设置 增加 是否默认选择分辨率(0.否,1.是)
* @param selectedIncrement
*/
public void setSelectedIncrement(Integer selectedIncrement){
this.selectedIncrement = selectedIncrement;
}
/**
* 获取 是否默认选择分辨率(0.否,1.是)
* @return selectedList
*/
public List<Integer> getSelectedList(){
return this.selectedList;
}
/**
* 设置 是否默认选择分辨率(0.否,1.是)
* @param selectedList
*/
public void setSelectedList(List<Integer> selectedList){
this.selectedList = selectedList;
}
/**
* 获取 是否默认选择分辨率(0.否,1.是)
* @return selectedNotList
*/
public List<Integer> getSelectedNotList(){
return this.selectedNotList;
}
/**
* 设置 是否默认选择分辨率(0.否,1.是)
* @param selectedNotList
*/
public void setSelectedNotList(List<Integer> selectedNotList){
this.selectedNotList = selectedNotList;
}
/**
* 设置 主键ID,主键,自增长
* @param id
......@@ -1348,6 +1444,60 @@ public class DeviceModuleDistributeQuery extends DeviceModuleDistributeEntity {
return this;
}
/**
* 设置 是否默认选择分辨率(0.否,1.是)
* @param selected
*/
public DeviceModuleDistributeQuery selected(Integer selected){
setSelected(selected);
return this;
}
/**
* 设置 开始 是否默认选择分辨率(0.否,1.是)
* @param selectedStart
*/
public DeviceModuleDistributeQuery selectedStart(Integer selectedStart){
this.selectedStart = selectedStart;
return this;
}
/**
* 设置 结束 是否默认选择分辨率(0.否,1.是)
* @param selectedEnd
*/
public DeviceModuleDistributeQuery selectedEnd(Integer selectedEnd){
this.selectedEnd = selectedEnd;
return this;
}
/**
* 设置 增加 是否默认选择分辨率(0.否,1.是)
* @param selectedIncrement
*/
public DeviceModuleDistributeQuery selectedIncrement(Integer selectedIncrement){
this.selectedIncrement = selectedIncrement;
return this;
}
/**
* 设置 是否默认选择分辨率(0.否,1.是)
* @param selectedList
*/
public DeviceModuleDistributeQuery selectedList(List<Integer> selectedList){
this.selectedList = selectedList;
return this;
}
/**
* 设置 是否默认选择分辨率(0.否,1.是)
* @param selectedNotList
*/
public DeviceModuleDistributeQuery selectedNotList(List<Integer> selectedNotList){
this.selectedNotList = selectedNotList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList
......
......@@ -16,6 +16,8 @@ public interface DeviceModuleDistributeService extends ICRUDService<DeviceModule
void active(DeviceModuleDistributeEntity distributeEntity, Context context);
Rest<String> selected(DeviceModuleDistributeEntity distributeEntity, Context context);
Rest<String> cloneAppBySite(DeviceModuleDistributeEntity deviceModuleDistributeEntity, Context context);
}
\ No newline at end of file
......@@ -22,11 +22,13 @@ import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.utils.EncodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.io.File;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* DeviceModuleDistributeService
......@@ -46,11 +48,8 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D
@Override
protected void saveBefore(DeviceModuleDistributeEntity entity, Context context) throws AppException {
ProductEntity productEntity = productService.get(entity.getProductId(), context);
entity.setProductCode(productEntity.getProductCode());
entity.setProductName(productEntity.getProductName());
entity.setImageResolutionValue(ImageReEnum.getByValue(Integer.parseInt(entity.getImageResolution())).getDesc());
super.saveBefore(entity, context);
}
......@@ -75,7 +74,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D
if (!FileUtil.getSuffix(distributeEntity.getFilePath()).equals("zip")) {
throw new AppException("部署只支持zip文件!");
}
//RuntimeUtil
//部署路径是否存在 如果不存在 创建目录,
String path = GlobalSysInfo.getParamValue(Constant.DISTRIBUTE_PATH, "/home/publish/app/homeDeviceUrl");
......@@ -104,6 +102,35 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDServiceImpl<D
this.update(distributeEntity, context);
}
@Override
public Rest<String> selected(DeviceModuleDistributeEntity distributeEntity, Context context) {
//选择默认资源默认分辨率
//如果选择的资源未部署,则提示先部署后才能选择
DeviceModuleDistributeEntity deviceModuleDistributeEntity = this.get(distributeEntity.getId(), context);
if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity) && deviceModuleDistributeEntity.getDistribute() == YesNoEnum.NO.getValue()) {
throw new AppException("选择的默认资源需先部署后才能选择!");
}
//查询同类资源,变更为非默认值后 再更新
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setProductId(deviceModuleDistributeEntity.getProductId());
List<Long> idList = this.find(query, context).stream().map(i -> i.getId()).collect(Collectors.toList());
DeviceModuleDistributeQuery condition = new DeviceModuleDistributeQuery();
condition.setIdList(idList);
DeviceModuleDistributeEntity entity = new DeviceModuleDistributeEntity();
entity.setSelected(YesNoEnum.NO.getValue());
this.updateBatch(entity, condition, context);
distributeEntity.setSelected(YesNoEnum.YES.getValue());
distributeEntity.setUpdateTime(new Date());
distributeEntity.setUpdateUserId(this.getContextUserId(context));
return Rest.ok();
}
@Override
public Rest<String> cloneAppBySite(DeviceModuleDistributeEntity deviceModuleDistributeEntity, Context context) {
......
......@@ -13,6 +13,7 @@ import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.ImageReEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeQuery;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
......@@ -30,7 +31,6 @@ import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/**
*
* 设备前端模块部署
*
* @author zxfei
......@@ -38,15 +38,15 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
*/
@RestController
@RequestMapping("device/module/distribute")
public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingController<DeviceModuleDistributeService,DeviceModuleDistributeEntity,Long> {
public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingController<DeviceModuleDistributeService, DeviceModuleDistributeEntity, Long> {
@Autowired
private ParamService paramService;
@Autowired
private ProductService productService;
public DeviceModuleDistributeController(){
super.setModuleDesc( "设备前端模块部署");
public DeviceModuleDistributeController() {
super.setModuleDesc("设备前端模块部署");
}
@Override
......@@ -60,6 +60,8 @@ public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingCon
this.addDict(model, "imageResolution", skinProductCodeMap);
}*/
this.addDict(model, "selected", YesNoEnum.getEnumMap());
this.addDict(model, "imageResolution", ImageReEnum.getEnumMap());
super.init(model, context);
}
......@@ -103,25 +105,61 @@ public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingCon
}
/**
* 默认选择
*/
@PostMapping(value = "selected")
public Rest<Void> selected(@RequestBody DeviceModuleDistributeEntity moduleDistributeEntity) {
String busiDesc = this.getModuleDesc() + "资源默认选择";
Rest<Void> rest = Rest.ok(busiDesc + " 【成功】");
try {
this.service.selected(moduleDistributeEntity, getContext());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("设备模块部署", e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
@Override
protected int viewAfter(Long id, Map<String, Object> model, DeviceModuleDistributeEntity entity, Context context) throws AppException {
protected void saveBefore(DeviceModuleDistributeEntity entity, Map<String, Object> model, Context context) throws AppException {
ProductEntity productEntity = productService.get(entity.getProductId(), context);
entity.setProductCode(productEntity.getProductCode());
entity.setProductName(productEntity.getProductName());
entity.setImageResolutionValue(ImageReEnum.getByValue(Integer.parseInt(entity.getImageResolution())).getDesc());
//查询新增的是否存在,如果存在 则更新,标准为分辨率+产品
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setSiteId(entity.getSiteId());
query.setProductId(entity.getProductId());
query.setImageResolution(entity.getImageResolution());
DeviceModuleDistributeEntity deviceModuleDistributeEntity = this.service.selectOne(query, context);
if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
entity.setId(deviceModuleDistributeEntity.getId());
}
}
@Override
protected int viewAfter(Long id, Map<String, Object> model, DeviceModuleDistributeEntity entity, Context context) throws AppException {
String serverName = request.getHeader("server-name");
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"),0);
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0);
String homeUrl="";
String homeUrl = "";
ProductEntity productEntity = productService.get(entity.getProductId(), context);
if(!ObjectUtils.isEmpty(productEntity.getHomeUrl())){
homeUrl= productEntity.getHomeUrl();
if (!ObjectUtils.isEmpty(productEntity.getHomeUrl())) {
homeUrl = productEntity.getHomeUrl();
}
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
if(!ObjectUtils.isEmpty(serverName)&& Validator.isIpv4(serverName)){
String str = UrlBuilder.ofHttp(serverName).setPort(serverPort>0?serverPort:11078).addPath(homeUrl).build();
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
String str = UrlBuilder.ofHttp(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
entity.setFilePath(decodeStr);
}else{
} else {
String str = UrlBuilder.of(domain.trim()).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
entity.setFilePath(decodeStr);
......
......@@ -2,14 +2,13 @@ package com.mortals.xhx.module.product.model;
import com.mortals.framework.annotation.Excel;
import com.mortals.xhx.module.product.model.vo.ProductVo;
import lombok.Data;
/**
* 产品实体对象
*
* @author zxfei
* @date 2023-08-21
* @date 2022-11-09
*/
@Data
public class ProductEntity extends ProductVo {
private static final long serialVersionUID = 1L;
......@@ -47,18 +46,126 @@ public class ProductEntity extends ProductVo {
* 备注
*/
private String productRemark;
public ProductEntity(){}
/**
* 获取 关联平台
* @return Long
*/
public Long getPlatformId(){
return platformId;
}
/**
* 设置 关联平台
* @param platformId
*/
public void setPlatformId(Long platformId){
this.platformId = platformId;
}
/**
* 获取 产品名称,名称唯一
* @return String
*/
public String getProductName(){
return productName;
}
/**
* 设置 产品名称,名称唯一
* @param productName
*/
public void setProductName(String productName){
this.productName = productName;
}
/**
* 获取 产品编码
* @return String
*/
public String getProductCode(){
return productCode;
}
/**
* 设置 产品编码
* @param productCode
*/
public void setProductCode(String productCode){
this.productCode = productCode;
}
/**
* 获取 皮肤id
* @return Long
*/
public Long getSkinId(){
return skinId;
}
/**
* 设置 皮肤id
* @param skinId
*/
public void setSkinId(Long skinId){
this.skinId = skinId;
}
/**
* 获取 皮肤名称
* @return String
*/
public String getSkinName(){
return skinName;
}
/**
* 设置 皮肤名称
* @param skinName
*/
public void setSkinName(String skinName){
this.skinName = skinName;
}
/**
* 站点Id,来源基础服务平台
* 获取 首页地址
* @return String
*/
private Long siteId;
public String getHomeUrl(){
return homeUrl;
}
/**
* 设置 首页地址
* @param homeUrl
*/
public void setHomeUrl(String homeUrl){
this.homeUrl = homeUrl;
}
/**
* 站点编号,来源基础服务平台
* 获取 事件地址,评价器使用
* @return String
*/
private String siteCode;
public String getEventUrl(){
return eventUrl;
}
/**
* 设置 事件地址,评价器使用
* @param eventUrl
*/
public void setEventUrl(String eventUrl){
this.eventUrl = eventUrl;
}
/**
* 获取 备注
* @return String
*/
public String getProductRemark(){
return productRemark;
}
/**
* 站点名称
* 设置 备注
* @param productRemark
*/
private String siteName;
public void setProductRemark(String productRemark){
this.productRemark = productRemark;
}
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -75,17 +182,35 @@ public class ProductEntity extends ProductVo {
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",platformId:").append(getPlatformId());
sb.append(",productName:").append(getProductName());
sb.append(",productCode:").append(getProductCode());
sb.append(",skinId:").append(getSkinId());
sb.append(",skinName:").append(getSkinName());
sb.append(",homeUrl:").append(getHomeUrl());
sb.append(",eventUrl:").append(getEventUrl());
sb.append(",productRemark:").append(getProductRemark());
return sb.toString();
}
public void initAttrValue(){
this.platformId = 0L;
this.platformId = null;
this.productName = "";
this.productCode = "";
this.skinId = 0L;
this.skinId = null;
this.skinName = "";
this.homeUrl = "";
this.eventUrl = "";
this.productRemark = "";
this.siteId = 0L;
this.siteCode = "";
this.siteName = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.product.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.product.model.ProductEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 产品视图对象
*
* @author zxfei
* @date 2022-07-01
*/
* 产品视图对象
*
* @author zxfei
* @date 2022-07-01
*/
@Data
public class ProductVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.product.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.module.product.model.ProductEntity;
......@@ -17,5 +18,7 @@ public interface ProductService extends ICRUDCacheService<ProductEntity,Long>{
void upGrade(Long productId, Context context);
Rest<String> cloneProductBySite(ProductEntity productEntity, Context context);
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import cn.hutool.core.net.url.UrlPath;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
......@@ -13,14 +14,15 @@ import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.busiz.rsp.ProductVersionInfo;
import com.mortals.xhx.common.code.LogTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.model.*;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
......@@ -73,7 +75,8 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
private DeviceLogService deviceLogService;
@Autowired
private MessageProducer messageProducer;
@Autowired
private ISiteFeign siteFeign;
@Override
......@@ -129,8 +132,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
}
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().productId(productId));
deviceList.forEach(deviceEntity -> {
//TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode()).build();
......@@ -145,7 +146,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
header.put(MessageHeader.MESSAGESIGN, "abcd1234");
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()), header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
......@@ -159,14 +160,51 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,context);
log.info("【发送中】发送升级版本信息,设备编码:{}",deviceEntity.getDeviceCode());
deviceLogService.save(deviceLogEntity, context);
log.info("【发送中】发送升级版本信息,设备编码:{}", deviceEntity.getDeviceCode());
// deviceService.sendDeviceMessage(deviceEntity, info, header, Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()), callback, null);
});
}
@Override
public Rest<String> cloneProductBySite(ProductEntity productEntity, Context context) {
//拷贝应用
Long targetSiteId = productEntity.getTargetSiteId();
Long sourceSiteId = productEntity.getSourceSiteId();
Rest<SitePdu> sitePduRest = siteFeign.info(targetSiteId);
if (YesNoEnum.NO.getValue() == sitePduRest.getCode()) {
throw new AppException("未查询到当前站点!");
}
SitePdu sitePdu = sitePduRest.getData();
ProductQuery query = new ProductQuery();
query.setSiteId(sourceSiteId);
List<ProductEntity> productEntityList = this.find(query);
//如果已存在 则不复制
for (ProductEntity product : productEntityList) {
ProductQuery productQuery = new ProductQuery();
productQuery.setSiteId(targetSiteId);
productQuery.setProductCode(product.getProductCode());
int count = this.count(query, context);
if (count == 0) {
productEntity.setId(null);
productEntity.setSiteId(sitePdu.getId());
productEntity.setSiteName(sitePdu.getSiteName());
productEntity.setSiteCode(sitePdu.getSiteCode());
this.save(productEntity, context);
}
}
return Rest.ok();
}
private void buildDownloadUrl(ProductVersionEntity productVersionEntity, ProductVersionInfo productVersionInfo) {
String download = "";
if (!ObjectUtils.isEmpty(productVersionEntity.getFilePath())) {
......
......@@ -57,6 +57,8 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
super.init(model, context);
}
/**
* 产品升级版本
*/
......
......@@ -58,6 +58,7 @@ public class ProductVersionController extends BaseCRUDJsonBodyMappingController<
}
/**
* 发布
*/
......
......@@ -21,6 +21,7 @@
<result property="siteId" column="siteId" />
<result property="siteCode" column="siteCode" />
<result property="siteName" column="siteName" />
<result property="selected" column="selected" />
</resultMap>
......@@ -76,23 +77,26 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteName') or colPickMode == 1 and data.containsKey('siteName')))">
a.siteName,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('selected') or colPickMode == 1 and data.containsKey('selected')))">
a.selected,
</if>
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="DeviceModuleDistributeEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_device_module_distribute
(productId,productCode,productName,imageResolution,imageResolutionValue,filePath,distributeFilePath,version,distribute,createTime,updateUserId,updateTime,siteId,siteCode,siteName)
(productId,productCode,productName,imageResolution,imageResolutionValue,filePath,distributeFilePath,version,distribute,createTime,updateUserId,updateTime,siteId,siteCode,siteName,selected)
VALUES
(#{productId},#{productCode},#{productName},#{imageResolution},#{imageResolutionValue},#{filePath},#{distributeFilePath},#{version},#{distribute},#{createTime},#{updateUserId},#{updateTime},#{siteId},#{siteCode},#{siteName})
(#{productId},#{productCode},#{productName},#{imageResolution},#{imageResolutionValue},#{filePath},#{distributeFilePath},#{version},#{distribute},#{createTime},#{updateUserId},#{updateTime},#{siteId},#{siteCode},#{siteName},#{selected})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_device_module_distribute
(productId,productCode,productName,imageResolution,imageResolutionValue,filePath,distributeFilePath,version,distribute,createTime,updateUserId,updateTime,siteId,siteCode,siteName)
(productId,productCode,productName,imageResolution,imageResolutionValue,filePath,distributeFilePath,version,distribute,createTime,updateUserId,updateTime,siteId,siteCode,siteName,selected)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.productId},#{item.productCode},#{item.productName},#{item.imageResolution},#{item.imageResolutionValue},#{item.filePath},#{item.distributeFilePath},#{item.version},#{item.distribute},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.siteId},#{item.siteCode},#{item.siteName})
(#{item.productId},#{item.productCode},#{item.productName},#{item.imageResolution},#{item.imageResolutionValue},#{item.filePath},#{item.distributeFilePath},#{item.version},#{item.distribute},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.siteId},#{item.siteCode},#{item.siteName},#{item.selected})
</foreach>
</insert>
......@@ -159,6 +163,12 @@
<if test="(colPickMode==0 and data.containsKey('siteName')) or (colPickMode==1 and !data.containsKey('siteName'))">
a.siteName=#{data.siteName},
</if>
<if test="(colPickMode==0 and data.containsKey('selected')) or (colPickMode==1 and !data.containsKey('selected'))">
a.selected=#{data.selected},
</if>
<if test="(colPickMode==0 and data.containsKey('selectedIncrement')) or (colPickMode==1 and !data.containsKey('selectedIncrement'))">
a.selected=ifnull(a.selected,0) + #{data.selectedIncrement},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
......@@ -296,6 +306,18 @@
</if>
</foreach>
</trim>
<trim prefix="selected=(case" suffix="ELSE selected end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('selected')) or (colPickMode==1 and !item.containsKey('selected'))">
when a.id=#{item.id} then #{item.selected}
</when>
<when test="(colPickMode==0 and item.containsKey('selectedIncrement')) or (colPickMode==1 and !item.containsKey('selectedIncrement'))">
when a.id=#{item.id} then ifnull(a.selected,0) + #{item.selectedIncrement}
</when>
</choose>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
......@@ -766,6 +788,33 @@
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('selected')">
<if test="conditionParamRef.selected != null ">
${_conditionType_} a.selected = #{${_conditionParam_}.selected}
</if>
<if test="conditionParamRef.selected == null">
${_conditionType_} a.selected is null
</if>
</if>
<if test="conditionParamRef.containsKey('selectedList') and conditionParamRef.selectedList.size() > 0">
${_conditionType_} a.selected in
<foreach collection="conditionParamRef.selectedList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('selectedNotList') and conditionParamRef.selectedNotList.size() > 0">
${_conditionType_} a.selected not in
<foreach collection="conditionParamRef.selectedNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('selectedStart') and conditionParamRef.selectedStart != null">
${_conditionType_} a.selected <![CDATA[ >= ]]> #{${_conditionParam_}.selectedStart}
</if>
<if test="conditionParamRef.containsKey('selectedEnd') and conditionParamRef.selectedEnd != null">
${_conditionType_} a.selected <![CDATA[ <= ]]> #{${_conditionParam_}.selectedEnd}
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
......@@ -859,6 +908,11 @@
<if test='orderCol.siteName != null and "DESC".equalsIgnoreCase(orderCol.siteName)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('selected')">
a.selected
<if test='orderCol.selected != null and "DESC".equalsIgnoreCase(orderCol.selected)'>DESC</if>
,
</if>
</trim>
</if>
</sql>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment