diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java index 39f5dcc3..4d1755c9 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaType.java @@ -203,6 +203,12 @@ public class MaType extends BaseEntity { @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children = new ArrayList<>(); + /** + * 厂家规格型号 + */ + @ApiModelProperty(value = "厂家规格型号") + private String facModel; + public Long getTypeId() { @@ -550,4 +556,12 @@ public class MaType extends BaseEntity { public void setFinalPrice(String finalPrice) { this.finalPrice = finalPrice; } + + public String getFacModel() { + return facModel; + } + + public void setFacModel(String facModel) { + this.facModel = facModel; + } } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java index 3b0e47f1..75bb60b3 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/BackReceiveController.java @@ -13,6 +13,7 @@ import java.util.List; /** * 退料接收-app + * * @author bns_han */ @RestController @@ -32,8 +33,14 @@ public class BackReceiveController extends BaseController { @GetMapping("getbackReceiveList") public AjaxResult getbackReceiveList(BackApplyInfo record) { try { - List list = backReceiveService.getbackReceiveList(record); - return success(list); + if (record.getFlag() == 0) { + List list = backReceiveService.getbackReceiveList(record); + return success(list); + } else { + startPage(); + List list = backReceiveService.getbackReceiveList(record); + return success(getDataTable(list)); + } } catch (Exception e) { throw new RuntimeException(e); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java index 092a459d..bd12c738 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/BackApplyInfo.java @@ -51,6 +51,10 @@ public class BackApplyInfo { * 类型名称 */ private String typeName; + /** + * 协议号 + */ + private String agreementCode; /** * 规格编号 */ @@ -159,4 +163,7 @@ public class BackApplyInfo { * 退料数量 */ private String preNum; + private String startTime; + private String endTime; + private Integer flag; } diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml index a9eb290b..f2e4fd1e 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -583,35 +583,69 @@ SELECT bai.id, bai.`code`, - bai.task_id as taskId, - bai.back_person as backPerson, + bai.task_id AS taskId, + bai.back_person AS backPerson, bai.phone, bpl.lot_id, - bpl.lot_name as lotName, - bui.unit_id as unitId, - bui.unit_name as unitName, - bai.back_time as backTime, - tt.task_status as taskStatus, - tta.agreement_id as agreementId, - GROUP_CONCAT(DISTINCT bad.type_id) as typeId, - GROUP_CONCAT(mt2.type_name, '') AS typeName + bpl.lot_name AS lotName, + bui.unit_id AS unitId, + bui.unit_name AS unitName, + bai.back_time AS backTime, + bagi.agreement_code AS agreementCode, + tt.task_status AS taskStatus, + sd.`name` AS taskName, + tta.agreement_id AS agreementId, + GROUP_CONCAT( DISTINCT bad.type_id ) AS typeId, + GROUP_CONCAT( mt2.type_name, '' ) AS typeName FROM back_apply_info bai - LEFT JOIN back_apply_details bad on bad.parent_id=bai.id - LEFT JOIN tm_task tt on tt.task_id=bai.task_id - LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id - LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id - LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id - LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id - LEFT JOIN sys_user us on us.user_id=bai.create_by - LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id - LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id - LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id - LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id + LEFT JOIN back_apply_details bad ON bad.parent_id = bai.id + LEFT JOIN tm_task tt ON tt.task_id = bai.task_id + LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id + LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id + LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bagi.project_id + LEFT JOIN bm_unit_info bui ON bui.unit_id = bagi.unit_id + LEFT JOIN sys_user us ON us.user_id = bai.create_by + LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id + LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id + LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id + LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id + LEFT JOIN sys_dic sd ON sd.id = tt.task_status WHERE - tt.task_status in (38,39,40) - GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time - ORDER BY tt.task_status asc ,bai.create_time desc + tt.task_status IN ( 37, 38, 39, 40 ) + + and (bai.code like concat('%', #{keyWord}, '%') or + bagi.agreement_code like concat('%', #{keyWord}, '%')) + + + and bui.unit_id = #{unitId} + + + and bpl.lot_id = #{lotId} + + + and bagi.agreement_code like concat('%', #{agreementCode}, '%') + + + and tt.task_status = #{taskStatus} + + + AND bai.back_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59') + + GROUP BY + bai.id, + us.user_name, + bai.phone, + bpl.lot_name, + bui.unit_name, + bagi.plan_start_time + + HAVING + FIND_IN_SET(#{typeId}, GROUP_CONCAT(DISTINCT bad.type_id)) + + ORDER BY + tt.task_status ASC, + bai.create_time DESC - select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type, + select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id,m.unit_name, m.manage_type, m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load, m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl, mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId, - su.nick_name keeperUserName, mtr.user_id repairUserId, su1.nick_name repairUserName, mpi.prop_name, + su.nick_name keeperUserName, mtr.user_id repairUserId, su1.nick_name repairUserName,mpi.prop_id as propId, mpi.prop_name as propName, m.del_flag, m.create_by, m.create_time, - m.remark, m.company_id + m.remark, m.company_id,m.fac_model as facModel from ma_type m left join ma_prop_set mps on m.type_id = mps.type_id left join ma_prop_info mpi on mps.prop_id = mpi.prop_id @@ -334,7 +337,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl, mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId, su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time, - m.remark, m.company_id + m.remark, m.company_id,m.fac_model as facModel from ma_type m left join ma_prop_set mps on m.type_id = mps.type_id left join ma_prop_info mpi on mps.prop_id = mpi.prop_id diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java index 34c90e1e..ac6e3c6b 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/BackApplyController.java @@ -84,11 +84,17 @@ public class BackApplyController extends BaseController { */ @ApiOperation(value = "退料申请(查看)") @GetMapping("/getViewByApply") - public TableDataInfo getViewByApply(BackApplyInfo bean) { - startPage(); - bean.setFlag(0); - List list = backApplyService.getViewByApply(bean); - return getDataTable(list); + public AjaxResult getViewByApply(BackApplyInfo bean) { + if (bean.getViewWeb() == 1) { + bean.setFlag(0); + List list = backApplyService.getViewByApply(bean); + return AjaxResult.success(list); + } else { + startPage(); + bean.setFlag(0); + List list = backApplyService.getViewByApply(bean); + return AjaxResult.success(getDataTable(list)); + } } /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java index e9394e3b..ded459e7 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/BackApplyInfo.java @@ -245,4 +245,6 @@ public class BackApplyInfo extends BaseEntity { /** 前端条件查询所传退料时间 */ private String time; + private int viewWeb; + } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseMacodeInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseMacodeInfo.java index 5c9bb831..8cce80ce 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseMacodeInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseMacodeInfo.java @@ -112,6 +112,17 @@ public class PurchaseMacodeInfo extends BaseEntity /** 到货日期 */ @ApiModelProperty(value = "到货日期") private String arrivalTime; + /** 单位名称 */ + @ApiModelProperty(value = "单位名称") + private String unitName; + + public String getUnitName() { + return unitName; + } + + public void setUnitName(String unitName) { + this.unitName = unitName; + } @ApiModelProperty(value = "0,正常 1, 重复数据") private int statusFlag; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java index 2283b043..28da051c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java @@ -60,13 +60,11 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi } } } - int res = 0; + int res; try { //1. 判断是数量还是编号入库,保存到不同表 //1.1 如果是编号入库 if (dto.getIsCode()) { - /*插入ma_machine、ma_machine_label和ma_label_bind以及 - ma_type_put_in_storage_info表和ma_type_put_in_storage_details表*/ res = insertMaMachineInfo(dto, codeList); if (res == 0) { log.error("insertMaMachineInfo方法插入异常"); @@ -87,11 +85,9 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi } } } catch (Exception e) { - log.error(e.getMessage()); - // 添加事务回滚逻辑 + log.error("保存入库盘点异常:{}",e.getMessage()); + // 添加事务回滚逻辑,保证入库全部成功或者全部失败 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - } - if (res == 0) { return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } return AjaxResult.success(res); @@ -113,7 +109,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @return */ private int insertMaMachineInfo(SavePutInfoDto dto, List codeList) { - int num = 0; + int res = 0; for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); String code = codeList.get(i); @@ -125,21 +121,22 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi machIneDto.setPutInType(dto.getPutInType()); machIneDto.setNum(dto.getNum()); machIneDto.setCheckMan(dto.getCheckMan()); - num = inventoryAndWarehousingMapper.insertMachine(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_machine表失败"); - } - num = inventoryAndWarehousingMapper.insertMachineLabel(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_machine_label表失败"); - } - num = inventoryAndWarehousingMapper.insertLabelBind(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_label_bind表失败"); - } - num = getAnInt(machIneDto); + res += insertMachineInfo(machIneDto); } - return num; + return res; + } + + /** + * 方法抽取,保持到ma_machine、ma_machine_label和ma_label_bind + * @param machIneDto + * @return + */ + private int insertMachineInfo(MachIneDto machIneDto) { + int res = inventoryAndWarehousingMapper.insertMachine(machIneDto); + res += inventoryAndWarehousingMapper.insertMachineLabel(machIneDto); + res += inventoryAndWarehousingMapper.insertLabelBind(machIneDto); + res += insertTypePutInStorageInfo(machIneDto); + return res; } /** @@ -147,19 +144,12 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @param machIneDto * @return */ - private int getAnInt(MachIneDto machIneDto) { - int num; + private int insertTypePutInStorageInfo(MachIneDto machIneDto) { //插入ma_type_put_in_storage_info表,返回主键id - num = inventoryAndWarehousingMapper.saveInfo(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_info表失败"); - } + int res = inventoryAndWarehousingMapper.saveInfo(machIneDto); //ma_type_put_in_storage_details表 - num = inventoryAndWarehousingMapper.saveDetails(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_details表失败"); - } - return num; + res += inventoryAndWarehousingMapper.saveDetails(machIneDto); + return res; } @@ -180,16 +170,16 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @return */ private int insertPutInfo(SavePutInfoDto dto) { - int num = 0; + int res = 0; for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); machIneDto.setCreator(dto.getCreator()); machIneDto.setPutInType(dto.getPutInType()); machIneDto.setRemarks(dto.getRemarks()); - getAnInt(machIneDto); + res += insertTypePutInStorageInfo(machIneDto); //根据类型追加ma_type表里面的num - num = updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); + res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); } - return num; + return res; } } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml index a9363189..5603680b 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseMacodeInfoMapper.xml @@ -409,6 +409,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" pcd.type_id typeId, pcd.task_id taskId, mt.CODE specsCode, + mt.unit_name unitName, mt1.CODE typeCode, CASE diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml index 9be81e9f..28b90587 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml @@ -85,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY mt.type_id) AS subquery4 ON subquery4.type_id = mt.type_id LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id WHERE mt.`level` = 4 + and mt.del_flag = '0' and mt2.type_name like concat('%',#{typeName},'%') diff --git a/sgzb-modules/sgzb-system/pom.xml b/sgzb-modules/sgzb-system/pom.xml index 96019531..a71282f0 100644 --- a/sgzb-modules/sgzb-system/pom.xml +++ b/sgzb-modules/sgzb-system/pom.xml @@ -105,6 +105,11 @@ 4.1.2 + + com.tencentcloudapi + tencentcloud-sdk-java + 3.1.423 + diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/config/TencentSmsConfig.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/config/TencentSmsConfig.java new file mode 100644 index 00000000..6c3f6b90 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/config/TencentSmsConfig.java @@ -0,0 +1,41 @@ +package com.bonus.sgzb.system.config; + +import lombok.Data; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +/** + * + */ +@Data +@Configuration +@ConfigurationProperties(prefix = "tencent.sms") +public class TencentSmsConfig{ + + //api秘钥标识 + private String accessKeyId; + + //api秘钥 + private String accessKeySecret; + + //请求域名 + private String endpoint; + + //所属区域 + private String region; + + //腾讯云申请应用id + private String sdkAppId; + + //签名 + private String smsSign; + + //云平台模板id + private List templateId; + + + +} diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysSmsController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysSmsController.java index 30c89738..fbf4bb9e 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysSmsController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysSmsController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.Date; /** * Description: 短信控制器 @@ -26,6 +27,11 @@ public class SysSmsController extends BaseController { @Resource private ISysSmsService smsService; + /** + * 登录短信验证码 + * @param phone + * @return + */ @PostMapping("codeLogin") public AjaxResult codeLogin(@RequestParam(value = "phone") String phone){ try { @@ -35,6 +41,12 @@ public class SysSmsController extends BaseController { } } + /** + * 短信验证码校验 + * @param phone + * @param code + * @return + */ @PostMapping("checkCode") public AjaxResult codeLogin(@RequestParam(value = "phone") String phone, @RequestParam(value = "code") String code){ try { @@ -44,6 +56,12 @@ public class SysSmsController extends BaseController { } } + /** + * 验收通知短信 + * @param phone + * @param msg + * @return + */ @PostMapping("send") public AjaxResult send(@RequestParam(value = "phone") String phone, @RequestParam(value = "msg",required = false) String msg){ try { diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SelectServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SelectServiceImpl.java index 8161486c..48f4174c 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SelectServiceImpl.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SelectServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.system.service.impl; +import cn.hutool.core.collection.CollUtil; import com.bonus.sgzb.common.core.utils.GlobalConstants; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.system.domain.AgreementVo; @@ -42,13 +43,14 @@ public class SelectServiceImpl implements SelectService { @Override public AjaxResult getProData(SelectDto dto) { - List list = new ArrayList<>(); try { - list = mapper.getProData(dto); + List list = mapper.getProData(dto); + list.removeIf(item -> item == null); + return AjaxResult.success(list); } catch (Exception e) { log.error("工程-查询失败", e); } - return AjaxResult.success(list); + return AjaxResult.success(); } @Override diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java index dde5db05..5d44e70e 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysSmsServiceImpl.java @@ -1,16 +1,29 @@ package com.bonus.sgzb.system.service.impl; -import cn.hutool.http.HttpRequest; import com.alibaba.druid.util.StringUtils; +import com.alibaba.fastjson.JSONObject; import com.bonus.sgzb.common.core.constant.UserConstants; import com.bonus.sgzb.common.core.exception.ServiceException; import com.bonus.sgzb.common.core.utils.GlobalConstants; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.redis.service.RedisService; +import com.bonus.sgzb.system.config.TencentSmsConfig; import com.bonus.sgzb.system.service.ISysSmsService; +import com.tencentcloudapi.common.Credential; +import com.tencentcloudapi.common.exception.TencentCloudSDKException; +import com.tencentcloudapi.common.profile.ClientProfile; +import com.tencentcloudapi.common.profile.HttpProfile; +import com.tencentcloudapi.sms.v20210111.SmsClient; +import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest; +import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; +import com.tencentcloudapi.sms.v20210111.models.SendStatus; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -24,17 +37,27 @@ import static com.bonus.sgzb.common.core.web.domain.AjaxResult.success; * @Version 1.0 */ @Service +@Slf4j public class SysSmsServiceImpl implements ISysSmsService { @Resource private RedisService redisService; + @Resource + private TencentSmsConfig tencentSmsConfig; + /** * 短信URL */ private static final String URL = "http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!"; + /** + * 验收通知短信 + * @param phone 手机号 + * @param msg 内容 + * @return + */ @Override public AjaxResult sendSms(String phone, String msg) { if (phone == null || StringUtils.isEmpty(msg)) { @@ -43,13 +66,34 @@ public class SysSmsServiceImpl implements ISysSmsService { if (phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { return AjaxResult.error("手机号格式不正确"); } - return sendMsgByPhone(phone, msg); + try { + String[] args = msg.split(","); + String body = sendMessageNew(phone,tencentSmsConfig.getTemplateId().get(0),args); + return success("发送手机号码:" + phone + ",内容:" + msg + ",返回结果:" + body); + } catch (Exception e) { + return AjaxResult.error("发送失败:" + e.getMessage()); + } } + /** + * 登录短信验证码 + * @param phone 手机号 + * @return + */ @Override public AjaxResult codeLogin(String phone) { - // 校验手机号码 - return sendCodeByPhone(phone, null); + + try { + //获取六位验证码 + String code = getSixBitCode(); + //调用发送短信的方法 + String body = sendMessageNew(phone,tencentSmsConfig.getTemplateId().get(1),code); + // 存储验证码至Redis中,键值为:code_15588886157 , 有效期5,时间颗粒度为MINUTES:分钟 + redisService.setCacheObject("code_" + phone, code, 5L, TimeUnit.MINUTES); + return success("手机号:" + phone + ",用户登录验证码:" + code + ",返回结果:" + body); + } catch (Exception e) { + return AjaxResult.error("发送失败:" + e.getMessage()); + } } @@ -58,7 +102,7 @@ public class SysSmsServiceImpl implements ISysSmsService { * @param phone 手机号码 * @return AjaxResult对象 */ - private AjaxResult sendMsgByPhone(String phone, String msg) { +/* private AjaxResult sendMsgByPhone(String phone, String msg) { // 校验手机号码 if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { return AjaxResult.error("手机号码不正确"); @@ -76,7 +120,7 @@ public class SysSmsServiceImpl implements ISysSmsService { } catch (Exception e) { return AjaxResult.error("发送失败:" + e.getMessage()); } - } + }*/ /** @@ -84,7 +128,7 @@ public class SysSmsServiceImpl implements ISysSmsService { * @param phone 手机号码 * @return AjaxResult对象 */ - private AjaxResult sendCodeByPhone(String phone, String msg) { +/* private AjaxResult sendCodeByPhone(String phone, String msg) { // 校验手机号码 if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) { return AjaxResult.error("手机号格式错误,请输入11位数字号码"); @@ -108,7 +152,7 @@ public class SysSmsServiceImpl implements ISysSmsService { } catch (Exception e) { return AjaxResult.error("发送失败:" + e.getMessage()); } - } + }*/ /** @@ -146,6 +190,65 @@ public class SysSmsServiceImpl implements ISysSmsService { return String.valueOf(random.nextInt(900000) + 100000); } + /** + * 腾讯sms短信 + * @param mobilePhone + * @param templateId + * @param args + * @return + * @throws Exception + */ + public String sendMessageNew(String mobilePhone,String templateId, String... args) throws Exception { + try{ + // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密 + Credential cred = new Credential(tencentSmsConfig.getAccessKeyId(), tencentSmsConfig.getAccessKeySecret()); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint(tencentSmsConfig.getEndpoint()); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 第二个参数是地域信息 + SmsClient client = new SmsClient(cred, tencentSmsConfig.getRegion(), clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + SendSmsRequest req = new SendSmsRequest(); + //设置固定的参数 + req.setSmsSdkAppId(tencentSmsConfig.getSdkAppId());// 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId + req.setSignName(tencentSmsConfig.getSmsSign());//短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 + req.setTemplateId(templateId);//模板 ID: 必须填写已审核通过的模板 ID + //设置发送相关的参数 + //发送对象(最多200个) + String[] phoneNumberSet1 = mobilePhone.split(","); + for (int i = 0; i < phoneNumberSet1.length; i++) { + phoneNumberSet1[i] = "+86" + phoneNumberSet1[i]; + } + req.setPhoneNumberSet(phoneNumberSet1);//发送的手机号 + if(null != args && args.length > 0 && Arrays.stream(args) + .noneMatch(s -> s == null || s.trim().isEmpty())) { + String[] templateParamSet1 = args;//模板的参数 + req.setTemplateParamSet(templateParamSet1);//发送验证码 + } + // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 + log.info("腾讯云平台短信发送请求参数:{}", JSONObject.toJSONString(req)); + SendSmsResponse resp = client.SendSms(req); + // 输出json格式的字符串回包 + log.info("腾讯云平台短信发送响应结果:{}", JSONObject.toJSONString(resp)); + SendStatus[] sendStatusSet = resp.getSendStatusSet(); + List sendStatuses = Arrays.asList(sendStatusSet); + if (CollectionUtils.isNotEmpty(sendStatuses)){ + for (SendStatus sendStatus : sendStatuses) { + if (!"OK".equalsIgnoreCase(sendStatus.getCode())){ + throw new ServiceException(sendStatus.getMessage(),Integer.valueOf(sendStatus.getCode())); + } + } + } + return resp.getRequestId(); + } catch (TencentCloudSDKException e) { + e.printStackTrace(); + log.error("短信发送失败:{}", e.getMessage()); + throw new ServiceException(e.getMessage(),Integer.valueOf(e.getErrorCode())); + } + } } diff --git a/sgzb-modules/sgzb-system/src/main/resources/bootstrap.yml b/sgzb-modules/sgzb-system/src/main/resources/bootstrap.yml index b158a4e4..d67b9907 100644 --- a/sgzb-modules/sgzb-system/src/main/resources/bootstrap.yml +++ b/sgzb-modules/sgzb-system/src/main/resources/bootstrap.yml @@ -36,7 +36,23 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - +#腾讯云sms +tencent: + sms: + #api秘钥标识 + accessKeyId: AKIDrreCVaRKDtMcgfU5QW9iEfv67tMfldJn + #api秘钥 + accessKeySecret: OXUgeMo0yhBRTGo6sVu3yiFX4rQtAzc3 + #请求域名 + endpoint: sms.tencentcloudapi.com + #所属区域 + region: ap-guangzhou + #腾讯云申请应用id + sdkAppId: 1400494336 + #签名 + smsSign: 南方电网互联网 + #云平台模板id 2116937-验收通知 2115503-登录验证 + templateId: 2116937,2115503 diff --git a/sgzb-ui/src/views/store/newBuy/newDevices/newDevicesAccept.vue b/sgzb-ui/src/views/store/newBuy/newDevices/newDevicesAccept.vue index 812bb3ca..526c949f 100644 --- a/sgzb-ui/src/views/store/newBuy/newDevices/newDevicesAccept.vue +++ b/sgzb-ui/src/views/store/newBuy/newDevices/newDevicesAccept.vue @@ -182,7 +182,7 @@ - + @@ -504,7 +504,8 @@ export default { item.phone = item.telphone; }) let param = { - message:this.nform.notice, + // message:this.nform.notice, + message:`${this.getNowTime()},${this.taskInfo.code}`, taskId:this.taskInfo.taskId, bmNoticeInfoList:this.configUserList, } diff --git a/sgzb-ui/src/views/store/warehousing/putInStore.vue b/sgzb-ui/src/views/store/warehousing/putInStore.vue index 03a3bcb5..cd60f710 100644 --- a/sgzb-ui/src/views/store/warehousing/putInStore.vue +++ b/sgzb-ui/src/views/store/warehousing/putInStore.vue @@ -187,7 +187,7 @@ placeholder="请选择物品类型" :options="deviceTypeTree" :props="deviceTypeTreeProps" - v-model="deviceType" + v-model="codeForm.typeId" @change="deviceTypeChange" ref="deviceTypeCascader" style="width: 400px;" @@ -229,18 +229,18 @@ @@ -278,9 +278,9 @@ - + - + - + - +