diff --git a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java index ee169057..461d85aa 100644 --- a/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java +++ b/sgzb-auth/src/main/java/com/bonus/sgzb/auth/service/SysLoginService.java @@ -22,10 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 登录校验方法 @@ -212,7 +209,8 @@ public class SysLoginService { */ public void register(RegisterBody registerBody) { String username = registerBody.getUsername(); - String password = registerBody.getPassword(); + // 随机生成一个10位数密码 + String password = generateRandomPassword(10); String phone = registerBody.getPhone(); // 用户名或密码为空 错误 if (StringUtils.isAnyBlank(username, password)) { @@ -270,12 +268,16 @@ public class SysLoginService { } - public static long[] convertToLongArray(int num) { - String numStr = Integer.toString(num); - long[] longArray = new long[numStr.length()]; - for (int i = 0; i < numStr.length(); i++) { - longArray[i] = Long.parseLong(String.valueOf(numStr.charAt(i))); + // 生成一个随时length位数密码 + public static String generateRandomPassword(int length) { + String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuilder password = new StringBuilder(); + + for (int i = 0; i < length; i++) { + int index = random.nextInt(characters.length()); + password.append(characters.charAt(index)); } - return longArray; + return password.toString(); } } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java index 7ed9f392..5c8de556 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java @@ -45,8 +45,10 @@ public class LeaseOutDetailsController extends BaseController { int i = leaseOutDetailsService.bindMachineByRfid(maMachine); if (i == 0) { return AjaxResult.success("绑定成功"); + } else if (i == 1) { + return AjaxResult.error("未查询到该设备"); } else { - return AjaxResult.error("绑定失败"); + return AjaxResult.error("该设备已绑定"); } } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java index 0459ad88..73af574e 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java @@ -52,10 +52,14 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { @Override public int bindMachineByRfid(MaMachine maMachine) { List maMachineByMaIdAndMaCode = maMachineMapper.getMaMachineByMaIdAndMaCode(maMachine); - if (CollUtil.isNotEmpty(maMachineByMaIdAndMaCode)){ + if (CollUtil.isNotEmpty(maMachineByMaIdAndMaCode)) { for (MaMachine machine : maMachineByMaIdAndMaCode) { - machine.setRfidCode(maMachine.getRfidCode()); - maMachineMapper.updateMaMachine(machine); + if (StringUtils.isBlank(machine.getRfidCode())) { + machine.setRfidCode(maMachine.getRfidCode()); + maMachineMapper.updateMaMachine(machine); + } else { + return 2; + } } return 0; } @@ -65,9 +69,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { @Override @Transactional public AjaxResult submitOutRfid(List recordList) { - for (LeaseOutDetails bean : recordList){ + for (LeaseOutDetails bean : recordList) { AjaxResult ajaxResult = submitOut(bean); - if (ajaxResult.isError()){ + if (ajaxResult.isError()) { return ajaxResult; } } @@ -128,9 +132,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { leaseOutDetailsMapper.updateTaskStatus(taskId, 34); } int j = insSltInfo(taskId, record); - if (j > 0){ + if (j > 0) { return AjaxResult.success("领料出库成功!"); - }else { + } else { return AjaxResult.error("出库失败,更新设备规格库存数量时出错!"); } @@ -146,25 +150,25 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!"); } - public int insSltInfo(String taskId,LeaseOutDetails record){ + public int insSltInfo(String taskId, LeaseOutDetails record) { SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record); - if (sltAgreementInfo != null){ + if (sltAgreementInfo != null) { double num = Double.parseDouble(sltAgreementInfo.getNum()); double outNum = record.getOutNum(); sltAgreementInfo.setNum(String.valueOf(num + outNum)); return leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); - }else { + } else { String agreementId = leaseOutDetailsMapper.getAgreementId(taskId); String protocol = leaseOutDetailsMapper.getProtocol(agreementId); MaType ma = leaseOutDetailsMapper.getMaType(record.getTypeId()); - if (protocol.isEmpty()){ + if (protocol.isEmpty()) { ma.setFinalPrice(ma.getLeasePrice()); - }else { - if (protocol.equals("1")){ + } else { + if (protocol.equals("1")) { ma.setFinalPrice(ma.getLeasePrice()); - }else if (protocol.equals("2")){ + } else if (protocol.equals("2")) { ma.setFinalPrice(ma.getRentPrice()); - }else { + } else { ma.setFinalPrice(ma.getLeasePrice()); } } @@ -198,7 +202,6 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { } - @Override public List getMaMachineByRfidCode(String rfidCode) { return maMachineMapper.getMaMachineByRfidCode(rfidCode); 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 b751706c..eeb19e83 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 @@ -80,24 +80,47 @@ public class BackApplyController extends BaseController { /** * 退料申请详情 */ - @ApiOperation(value = "退料申请详情") - @GetMapping("/getView") - public TableDataInfo getView(BackApplyInfo bean) { + @ApiOperation(value = "退料申请(查看)") + @GetMapping("/getViewByApply") + public TableDataInfo getViewByApply(BackApplyInfo bean) { startPage(); - List list = backApplyService.getView(bean); + bean.setFlag(0); + List list = backApplyService.getViewByApply(bean); return getDataTable(list); } /** * 退料申请详情--用于退料单,不带分页 */ - @ApiOperation(value = "退料单") - @GetMapping("/materialReturnNote") - public AjaxResult materialReturnNote(BackApplyInfo bean) { + @ApiOperation(value = "退料申请(退料单、审批)") + @GetMapping("/materialReturnNoteByApply") + public AjaxResult materialReturnNoteByApply(BackApplyInfo bean) { + bean.setFlag(1); + List list = backApplyService.getViewByApply(bean); + return success(list); + } + /** + * 退料审核详情 + */ + @ApiOperation(value = "退料审核(查看)") + @GetMapping("/getViewByExamine") + public TableDataInfo getViewByExamine(BackApplyInfo bean) { + startPage(); + List list = backApplyService.getView(bean); + return getDataTable(list); + } + + /** + * 退料审核详情-不带分页 + */ + @ApiOperation(value = "退料审核(审批/退料单)") + @GetMapping("/materialReturnNoteByExamine") + public AjaxResult materialReturnNoteByExamine(BackApplyInfo bean) { List list = backApplyService.getView(bean); return success(list); } + /** * 退料申请详情修改 */ @@ -223,12 +246,24 @@ public class BackApplyController extends BaseController { /** * 退料申请导出 */ - @ApiOperation("退料申请导出") - @Log(title = "退料申请导出", businessType = BusinessType.EXPORT) + @ApiOperation("退料申请列表导出") + @Log(title = "退料申请列表导出", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, BackApplyInfo bean) { + public void exportApply(HttpServletResponse response, BackApplyInfo bean) { List list = backApplyService.getBackApplyList(bean); ExcelUtil util = new ExcelUtil(BackApplyInfo.class); util.exportExcel(response, list, "退料申请数据"); } + + /** + * 退料审核导出 + */ + @ApiOperation("退料审核列表导出") + @Log(title = "退料审核列表导出", businessType = BusinessType.EXPORT) + @PostMapping("/exportExamine") + public void exportExamine(HttpServletResponse response, BackApplyInfo bean) { + List list = backApplyService.getBackAuditList(bean); + ExcelUtil util = new ExcelUtil(BackApplyInfo.class); + util.exportExcel(response, 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 af8bca1a..054b22c3 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 @@ -21,10 +21,27 @@ public class BackApplyInfo extends BaseEntity { @ApiModelProperty(value = "退料ID") private Long id; + @ApiModelProperty(value="工程id") + private Long projectId; + /** + * 工程名称 + */ + @ApiModelProperty(value="工程名称") + private String proName; + /** 退料ID-字符串 */ @ApiModelProperty(value = "退料ID-字符串") private String ids; + private String applyStatus; + /** + * 装备管理方式(0编号 1计数) + */ + @ApiModelProperty(value = "装备管理方式名称") + private String manageTypeName; + + private int flag; + /** 退料单号 */ @Excel(name = "退料单号") @ApiModelProperty(value = "退料单号") diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java index 0babacd6..a6363ccf 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/BackApplyMapper.java @@ -23,6 +23,7 @@ public interface BackApplyMapper { List getBackApplyList(BackApplyInfo bean); List getBackApplyListByAdmin(BackApplyInfo bean); + List getBackApplyListByAdmin1(BackApplyInfo bean); /** * 获取在用物料列表 @@ -73,6 +74,7 @@ public interface BackApplyMapper { * @return */ List getView(BackApplyInfo bean); + List getViewByApply(BackApplyInfo bean); /** * 修改 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java index 557dfe95..3a5b2c21 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/BackApplyService.java @@ -70,6 +70,7 @@ public interface BackApplyService { * @return */ List getView(BackApplyInfo bean); + List getViewByApply(BackApplyInfo bean); /** * 退料申请详情修改 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java index 6465b3d8..238f59a9 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/BackApplyServiceImpl.java @@ -41,7 +41,7 @@ public class BackApplyServiceImpl implements BackApplyService { Set roles = SecurityUtils.getLoginUser().getRoles(); if (roles.contains("admin")) { //管理员可以看到所有退料申请 - return backApplyMapper.getBackApplyListByAdmin(bean); + return backApplyMapper.getBackApplyListByAdmin1(bean); } //个人只能看到自己的申请的退料 String username = SecurityUtils.getLoginUser().getUsername(); @@ -126,7 +126,30 @@ public class BackApplyServiceImpl implements BackApplyService { @Override public List getView(BackApplyInfo bean) { - return backApplyMapper.getView(bean); + Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId(); + if (companyId != null) { + bean.setCompanyId(companyId.toString()); + return backApplyMapper.getView(bean); + } else { + return backApplyMapper.getView(bean); + } + + } + + @Override + public List getViewByApply(BackApplyInfo bean) { + List viewByApply = backApplyMapper.getViewByApply(bean); + if (bean.getFlag() == 1) { + List backApplyInfos = new ArrayList<>(); + for (BackApplyInfo backApplyInfo : viewByApply) { + if ("2".equals(backApplyInfo.getStatus()) || "4".equals(backApplyInfo.getStatus())) { + backApplyInfos.add(backApplyInfo); + } + } + return backApplyInfos; + } + return viewByApply; + } @Override @@ -161,7 +184,7 @@ public class BackApplyServiceImpl implements BackApplyService { @Override public AjaxResult audit(BackApplyInfo bean) { Set roles = SecurityUtils.getLoginUser().getRoles(); - String username = SecurityUtils.getLoginUser().getUsername(); + Long userid = SecurityUtils.getLoginUser().getUserid(); Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId(); int num = 0; if (!StringUtils.isEmpty(bean.getIds())) { @@ -169,18 +192,26 @@ public class BackApplyServiceImpl implements BackApplyService { for (int i = 0; i < ids.length; i++) { String id = ids[i]; bean.setId(Long.valueOf(id)); - if (roles.contains("jjfgs") || roles.contains("admin")) { - bean.setCompanyId(companyId.toString()); - bean.setCreateBy(username); + if (roles.contains("admin")) { + bean.setCreateBy(userid.toString()); bean.setStatus("1"); int re = backApplyMapper.audit(bean); if (re < 1) { return AjaxResult.error("审核失败"); } } - if (roles.contains("tsfgs") || roles.contains("admin")) { + if (roles.contains("jjfgs")) { bean.setCompanyId(companyId.toString()); - bean.setCreateBy(username); + bean.setCreateBy(userid.toString()); + bean.setStatus("1"); + int re = backApplyMapper.audit(bean); + if (re < 1) { + return AjaxResult.error("审核失败"); + } + } + if (roles.contains("tsfgs")) { + bean.setCompanyId(companyId.toString()); + bean.setCreateBy(userid.toString()); bean.setStatus("3"); int re = backApplyMapper.audit(bean); if (re < 1) { @@ -209,7 +240,7 @@ public class BackApplyServiceImpl implements BackApplyService { @Override public AjaxResult refuse(BackApplyInfo bean) { Set roles = SecurityUtils.getLoginUser().getRoles(); - String username = SecurityUtils.getLoginUser().getUsername(); + Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId(); Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId(); int num = 0; if (!StringUtils.isEmpty(bean.getIds())) { @@ -217,18 +248,26 @@ public class BackApplyServiceImpl implements BackApplyService { for (int i = 0; i < ids.length; i++) { String id = ids[i]; bean.setId(Long.valueOf(id)); - if (roles.contains("jjfgs") || roles.contains("admin")) { - bean.setCompanyId(companyId.toString()); - bean.setCreateBy(username); + if (roles.contains("admin")) { + bean.setCreateBy(userId.toString()); bean.setStatus("2"); int re = backApplyMapper.refuse(bean); if (re < 1) { return AjaxResult.error("驳回失败"); } } - if (roles.contains("tsfgs") || roles.contains("admin")) { + if (roles.contains("jjfgs")) { bean.setCompanyId(companyId.toString()); - bean.setCreateBy(username); + bean.setCreateBy(userId.toString()); + bean.setStatus("2"); + int re = backApplyMapper.refuse(bean); + if (re < 1) { + return AjaxResult.error("驳回失败"); + } + } + if (roles.contains("tsfgs")) { + bean.setCompanyId(companyId.toString()); + bean.setCreateBy(userId.toString()); bean.setStatus("4"); int re = backApplyMapper.refuse(bean); if (re < 1) { @@ -243,7 +282,7 @@ public class BackApplyServiceImpl implements BackApplyService { } } } - if (num == taskIdById.size()) { + if (num > 0) { bean.setTaskStatus("101"); backApplyMapper.updateTmTask(bean); } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml index 878a16a5..4e45882e 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/BackApplyMapper.xml @@ -257,7 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE bai.id = #{id} - and bai.company_id = #{companyId}, + and bai.company_id = #{companyId} @@ -265,11 +265,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UPDATE tm_task tt LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id LEFT JOIN back_apply_details bad on bad.parent_id=bai.id - SET bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bad.status=#{status},bai.direct_audit_time=NOW() + SET bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bai.status=#{status},bai.direct_audit_time=NOW() WHERE bai.id = #{id} - and bai.company_id = #{companyId}, + and bai.company_id = #{companyId} @@ -304,6 +304,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bai.id, bai.`code`, bai.back_person as backPerson, + bai.`status` as applyStatus, bai.phone, bpl.lot_id as lotId, bpl.lot_name as lotName, @@ -352,7 +353,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bai.back_time =#{time} - GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time + GROUP BY bai.task_id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time ORDER BY bai.create_time desc @@ -433,6 +434,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM back_apply_details bad LEFT JOIN back_apply_info bai ON bai.id = bad.parent_id + LEFT JOIN tm_task tt on bai.task_id = tt.task_id LEFT JOIN tm_task_agreement tta ON tta.task_id = bai.task_id LEFT JOIN bm_agreement_info bagi ON bagi.agreement_id = tta.agreement_id LEFT JOIN bm_project_lot lot ON lot.lot_id = bagi.project_id @@ -443,7 +445,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id WHERE - bai.id = #{id} + bai.task_id = #{taskId} + + and bai.company_id = #{companyId} + and (mt2.type_name like concat('%', #{keyWord}, '%') or mt.type_name like concat('%', #{keyWord}, '%')) @@ -588,8 +593,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT bai.id, bai.`code`, + bai.`status` as applyStatus, bai.back_person as backPerson, bai.phone, + bai.task_id as taskId, bpl.lot_id as lotId, bpl.lot_name as lotName, bui.unit_id as unitId, @@ -648,5 +655,102 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" (SELECT * FROM back_apply_info bai2 WHERE bai2.id = #{id}) dd on bai1.task_id = dd.task_id + + \ No newline at end of file