Commit dfb0293c5526ac5687c83f718a176f300d94f78c

Authored by 房远帅
1 parent 0f0aa675

试样订单:产品试样确单-审核

... ... @@ -128,6 +128,18 @@ public class ProductSampleConfirmationSlip extends BaseEntity implements BaseDto
128 128 private boolean showExamine;
129 129
130 130 /**
  131 + * 分厂编码
  132 + */
  133 + @TableField(exist = false)
  134 + private String workshopCode;
  135 +
  136 + /**
  137 + * 办事处编码
  138 + */
  139 + @TableField(exist = false)
  140 + private String deptCode;
  141 +
  142 + /**
131 143 * 办事处内勤ID
132 144 */
133 145 private String officeClerk;
... ...
... ... @@ -182,6 +182,12 @@ public class PurchaseOrderInfo extends BaseEntity implements BaseDto {
182 182 private String deptName;
183 183
184 184 /**
  185 + * 办事处编码(非持久化字段)
  186 + */
  187 + @TableField(exist = false)
  188 + private String deptCode;
  189 +
  190 + /**
185 191 * 区域
186 192 */
187 193 private String region;
... ...
... ... @@ -204,6 +204,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
204 204 case "FUND_COORDINATION":
205 205 handleFundCoordinationData(flowStatus, businessId);
206 206 break;
  207 + case "CONFIRMATION_SLIP":
  208 + handleConfirmationSlipData(flowStatus, businessId);
  209 + break;
207 210 default:
208 211 break;
209 212 }
... ... @@ -839,4 +842,16 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
839 842 }
840 843 }
841 844 }
  845 +
  846 + //产品试样确认单
  847 + private void handleConfirmationSlipData(String flowStatus, String businessId) {
  848 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  849 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  850 + productSampleConfirmationSlipService.updateStatus(businessId, "PASS");
  851 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  852 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  853 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  854 + productSampleConfirmationSlipService.updateStatus(businessId, "REFUSE");
  855 + }
  856 + }
842 857 }
... ...
... ... @@ -14,14 +14,17 @@ import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
14 14 import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
15 15 import com.lframework.starter.web.inner.service.system.SysUserRoleService;
16 16 import com.lframework.xingyun.sc.entity.FundCoordination;
  17 +import com.lframework.xingyun.sc.entity.ProductSampleConfirmationSlip;
17 18 import com.lframework.xingyun.sc.handlers.TransactorHandler;
18 19 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
19 20 import com.lframework.xingyun.sc.service.ledger.FundCoordinationService;
20 21 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
21 22 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
  23 +import com.lframework.xingyun.sc.service.sample.ProductSampleConfirmationSlipService;
22 24 import com.lframework.xingyun.sc.vo.customer.credit.*;
23 25 import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
24 26 import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo;
  27 +import com.lframework.xingyun.sc.vo.sample.confirm.UpdateProductSampleConfirmationSlipVo;
25 28 import org.apache.commons.collections.CollectionUtils;
26 29 import org.springframework.stereotype.Service;
27 30 import org.springframework.transaction.annotation.Transactional;
... ... @@ -46,6 +49,8 @@ public class FlowTaskServiceImpl implements FlowTaskService {
46 49 private TransactorHandler transactorHandler;
47 50 @Resource
48 51 private SysUserRoleService sysUserRoleService;
  52 + @Resource
  53 + private ProductSampleConfirmationSlipService productSampleConfirmationSlipService;
49 54
50 55
51 56 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"})
... ... @@ -294,4 +299,45 @@ public class FlowTaskServiceImpl implements FlowTaskService {
294 299 }
295 300
296 301 }
  302 +
  303 + @OpLog(type = OtherOpLogType.class, name = "更新产品试样确认单,ID:{}", params = {"#id"})
  304 + @Transactional(rollbackFor = Exception.class)
  305 + @Override
  306 + public void updateConfirmationSlipMap(Map<String, Object> map) {
  307 + //流程编码
  308 + Object n = map.get("nodeCode");
  309 + String nodeCode = String.valueOf(n);
  310 + //审核意见
  311 + Object m = map.get("message");
  312 + String message = String.valueOf(m);
  313 + //审核状态
  314 + Object r = map.get("review");
  315 + String review = String.valueOf(r);
  316 + //主键
  317 + Object i = map.get("id");
  318 + String id = String.valueOf(i);
  319 + ProductSampleConfirmationSlip data = productSampleConfirmationSlipService.findById(id);
  320 + if (ObjectUtil.isNull(data)) {
  321 + throw new DefaultClientException("产品试样确认单不存在!");
  322 + }
  323 + //审核人
  324 + String userId = SecurityUtil.getCurrentUser().getId();
  325 + //更新审核人及意见
  326 + productSampleConfirmationSlipService.updateExamine(id, userId, nodeCode, message, review);
  327 +
  328 + if ("confirmation_slip_1".equals(nodeCode) || "confirmation_slip_2".equals(nodeCode)) {
  329 + // 创建 ObjectMapper 实例
  330 + ObjectMapper objectMapper = new ObjectMapper();
  331 + try {
  332 + // 方法1:先将 Map 序列化为 JSON 字符串,再反序列化为目标对象
  333 + String json = objectMapper.writeValueAsString(map);
  334 + UpdateProductSampleConfirmationSlipVo updateConfirmationSlipVo = JsonUtil.parseObject(json, UpdateProductSampleConfirmationSlipVo.class);
  335 + // 使用转换后的对象
  336 + System.out.println("===updateConfirmationSlipVo:" + updateConfirmationSlipVo);
  337 + productSampleConfirmationSlipService.updateNoFlowInstance(updateConfirmationSlipVo);
  338 + } catch (JsonProcessingException e) {
  339 + e.printStackTrace();
  340 + }
  341 + }
  342 + }
297 343 }
... ...
... ... @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 5 import com.github.pagehelper.PageInfo;
6 6 import com.lframework.starter.bpm.dto.FlowTaskDto;
7 7 import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  8 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
8 9 import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
9 10 import com.lframework.starter.web.core.components.security.SecurityUtil;
10 11 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
... ... @@ -20,13 +21,17 @@ import com.lframework.starter.web.core.components.resp.PageResult;
20 21 import com.lframework.starter.common.utils.StringUtil;
21 22 import com.lframework.starter.common.utils.ObjectUtil;
22 23 import com.lframework.starter.common.utils.Assert;
  24 +import com.lframework.xingyun.basedata.entity.Workshop;
  25 +import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
23 26 import com.lframework.xingyun.sc.entity.ProductSampleConfirmationSlip;
24 27 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
25 28 import com.lframework.xingyun.sc.mappers.ProductSampleConfirmationSlipMapper;
  29 +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
26 30 import com.lframework.xingyun.sc.service.sample.ProductSampleConfirmationSlipDetailService;
27 31 import com.lframework.xingyun.sc.service.sample.ProductSampleConfirmationSlipService;
28 32 import com.lframework.xingyun.sc.vo.sample.confirm.*;
29 33 import org.apache.commons.collections.CollectionUtils;
  34 +import org.apache.commons.lang3.StringUtils;
30 35 import org.springframework.transaction.annotation.Transactional;
31 36 import org.springframework.stereotype.Service;
32 37 import javax.annotation.Resource;
... ... @@ -35,10 +40,17 @@ import java.util.stream.Collectors;
35 40
36 41 @Service
37 42 public class ProductSampleConfirmationSlipServiceImpl extends BaseMpServiceImpl<ProductSampleConfirmationSlipMapper, ProductSampleConfirmationSlip> implements ProductSampleConfirmationSlipService {
  43 + private static final String BPM_FLAG = "CONFIRMATION_SLIP";
38 44 @Resource
39 45 private ProductSampleConfirmationSlipDetailService productSampleConfirmationSlipDetailService;
40 46 @Resource
41 47 private FlowTaskWrapperMapper flowTaskWrapperMapper;
  48 + @Resource
  49 + private WorkshopService workshopService;
  50 + @Resource
  51 + private PurchaseOrderInfoService purchaseOrderInfoService;
  52 + @Resource
  53 + private FlowInstanceWrapperService flowInstanceWrapperService;
42 54
43 55 @Override
44 56 public PageResult<ProductSampleConfirmationSlip> query(Integer pageIndex, Integer pageSize, QueryProductSampleConfirmationSlipVo vo) {
... ... @@ -153,6 +165,141 @@ public class ProductSampleConfirmationSlipServiceImpl extends BaseMpServiceImpl<
153 165 productSampleConfirmationSlipDetailService.update(vo1);
154 166 }
155 167 }
  168 + //开启审核
  169 + ProductSampleConfirmationSlip result = getBaseMapper().findById(vo.getId());
  170 + if (StringUtils.isNotEmpty(result.getWorkshopId())) {
  171 + Workshop workshop = workshopService.findById(result.getWorkshopId());
  172 + if (workshop != null) {
  173 + result.setWorkshopCode(workshop.getCode());
  174 + }
  175 + }
  176 + PurchaseOrderInfo orderInfo = purchaseOrderInfoService.findById(result.getOrderId());
  177 + if (orderInfo != null) {
  178 + result.setDeptCode(orderInfo.getDeptCode());
  179 + }
  180 + flowInstanceWrapperService.startInstance(BPM_FLAG, result.getId(), BPM_FLAG, result);
  181 + }
  182 +
  183 + @OpLog(type = OtherOpLogType.class, name = "修改产品试样确认单不走审核,ID:{}", params = {"#id"})
  184 + @Transactional(rollbackFor = Exception.class)
  185 + @Override
  186 + public void updateNoFlowInstance(UpdateProductSampleConfirmationSlipVo vo) {
  187 +
  188 + ProductSampleConfirmationSlip data = getBaseMapper().selectById(vo.getId());
  189 + if (ObjectUtil.isNull(data)) {
  190 + throw new DefaultClientException("产品试样确认单不存在!");
  191 + }
  192 +
  193 + LambdaUpdateWrapper<ProductSampleConfirmationSlip> updateWrapper = Wrappers.lambdaUpdate(ProductSampleConfirmationSlip.class)
  194 + .set(ProductSampleConfirmationSlip::getSampleType, StringUtil.isBlank(vo.getSampleType()) ? null : vo.getSampleType())
  195 + .set(ProductSampleConfirmationSlip::getCustomerType, StringUtil.isBlank(vo.getCustomerType()) ? null : vo.getCustomerType())
  196 + .set(ProductSampleConfirmationSlip::getOriginalSupplierPeer, StringUtil.isBlank(vo.getOriginalSupplierPeer()) ? null : vo.getOriginalSupplierPeer())
  197 + .set(ProductSampleConfirmationSlip::isSampleQuantityRegulation, vo.isSampleQuantityRegulation())
  198 + .set(ProductSampleConfirmationSlip::isSpecificationQuantityRegulation, vo.isSpecificationQuantityRegulation())
  199 + .set(ProductSampleConfirmationSlip::getSampleFrequency, StringUtil.isBlank(vo.getSampleFrequency()) ? null : vo.getSampleFrequency())
  200 + .set(ProductSampleConfirmationSlip::getEarlyNonconformityDescription, StringUtil.isBlank(vo.getEarlyNonconformityDescription()) ? null : vo.getEarlyNonconformityDescription())
  201 + .eq(ProductSampleConfirmationSlip::getId, vo.getId());
  202 +
  203 + getBaseMapper().update(updateWrapper);
  204 +
  205 + OpLogUtil.setVariable("id", data.getId());
  206 + OpLogUtil.setExtra(vo);
  207 + //明细数据
  208 + List<UpdateProductSampleConfirmationSlipDetailVo> detailList = vo.getProductSampleConfirmationSlipDetailList();
  209 + if (CollectionUtils.isNotEmpty(detailList)) {
  210 + for (UpdateProductSampleConfirmationSlipDetailVo vo1 : detailList) {
  211 + productSampleConfirmationSlipDetailService.update(vo1);
  212 + }
  213 + }
  214 + }
  215 +
  216 + @OpLog(type = OtherOpLogType.class, name = "修改产品试样确认单审核人及意见,ID:{}", params = {"#id"})
  217 + @Transactional(rollbackFor = Exception.class)
  218 + @Override
  219 + public void updateExamine(String id, String userId, String nodeCode, String message, String review) {
  220 +
  221 + ProductSampleConfirmationSlip data = getBaseMapper().findById(id);
  222 + if (ObjectUtil.isNull(data)) {
  223 + throw new DefaultClientException("产品试样确认单不存在!");
  224 + }
  225 + LambdaUpdateWrapper<ProductSampleConfirmationSlip> updateWrapper = Wrappers.lambdaUpdate(ProductSampleConfirmationSlip.class);
  226 + if (nodeCode.equals("confirmation_slip_1")) {
  227 + //办事处内勤
  228 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeClerk, StringUtil.isBlank(userId) ? null : userId);
  229 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeClerkReview, StringUtil.isBlank(review) ? null : review);
  230 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  231 + } else if (nodeCode.equals("confirmation_slip_2")) {
  232 + //办事处主管
  233 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeSupervisor, StringUtil.isBlank(userId) ? null : userId);
  234 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeSupervisorReview, StringUtil.isBlank(review) ? null : review);
  235 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeSupervisorOpinion, StringUtil.isBlank(message) ? null : message);
  236 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  237 + } else if (nodeCode.startsWith("confirmation_slip_3-")) {
  238 + //办事处分管
  239 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDeputyDirector, StringUtil.isBlank(userId) ? null : userId);
  240 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDeputyDirectorReview, StringUtil.isBlank(review) ? null : review);
  241 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDeputyDirectorOpinion, StringUtil.isBlank(message) ? null : message);
  242 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  243 + } else if (nodeCode.equals("confirmation_slip_4-")) {
  244 + //分厂经营办主管
  245 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeManagementSupervisor, StringUtil.isBlank(userId) ? null : userId);
  246 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeManagementSupervisorReview, StringUtil.isBlank(review) ? null : review);
  247 + updateWrapper.set(ProductSampleConfirmationSlip::getOfficeManagementSupervisorOpinion, StringUtil.isBlank(message) ? null : message);
  248 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  249 + } else if (nodeCode.equals("confirmation_slip_5-")) {
  250 + //分厂品质经理
  251 + updateWrapper.set(ProductSampleConfirmationSlip::getQualityManager, StringUtil.isBlank(userId) ? null : userId);
  252 + updateWrapper.set(ProductSampleConfirmationSlip::getQualityManagerReview, StringUtil.isBlank(review) ? null : review);
  253 + updateWrapper.set(ProductSampleConfirmationSlip::getQualityManagerOpinion, StringUtil.isBlank(message) ? null : message);
  254 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  255 + } else if (nodeCode.equals("confirmation_slip_6-")) {
  256 + //分厂主管
  257 + updateWrapper.set(ProductSampleConfirmationSlip::getBranchFactorySupervisor, StringUtil.isBlank(userId) ? null : userId);
  258 + updateWrapper.set(ProductSampleConfirmationSlip::getBranchFactorySupervisorReview, StringUtil.isBlank(review) ? null : review);
  259 + updateWrapper.set(ProductSampleConfirmationSlip::getBranchFactorySupervisorOpinion, StringUtil.isBlank(message) ? null : message);
  260 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  261 + } else if (nodeCode.equals("confirmation_slip_7")) {
  262 + //营销部主管
  263 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDepartmentManager, StringUtil.isBlank(userId) ? null : userId);
  264 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDepartmentManagerReview, StringUtil.isBlank(review) ? null : review);
  265 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingDepartmentManagerOpinion, StringUtil.isBlank(message) ? null : message);
  266 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  267 + } else if (nodeCode.equals("confirmation_slip_8")) {
  268 + //营销中心主管
  269 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingCenterSupervisor, StringUtil.isBlank(userId) ? null : userId);
  270 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingCenterSupervisorReview, StringUtil.isBlank(review) ? null : review);
  271 + updateWrapper.set(ProductSampleConfirmationSlip::getMarketingCenterSupervisorOpinion, StringUtil.isBlank(message) ? null : message);
  272 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  273 + } else if (nodeCode.equals("confirmation_slip_9")) {
  274 + //总经理
  275 + updateWrapper.set(ProductSampleConfirmationSlip::getGeneralManager, StringUtil.isBlank(userId) ? null : userId);
  276 + updateWrapper.set(ProductSampleConfirmationSlip::getGeneralManagerReview, StringUtil.isBlank(review) ? null : review);
  277 + updateWrapper.set(ProductSampleConfirmationSlip::getGeneralManagerOpinion, StringUtil.isBlank(message) ? null : message);
  278 + updateWrapper.eq(ProductSampleConfirmationSlip::getId, id);
  279 + }
  280 + getBaseMapper().update(updateWrapper);
  281 +
  282 + OpLogUtil.setVariable("id", data.getId());
  283 + OpLogUtil.setExtra(id);
  284 + }
  285 +
  286 + @OpLog(type = OtherOpLogType.class, name = "修改审核状态,ID:{}", params = {"#id"})
  287 + @Transactional(rollbackFor = Exception.class)
  288 + @Override
  289 + public void updateStatus(String id, String status) {
  290 +
  291 + ProductSampleConfirmationSlip data = getBaseMapper().selectById(id);
  292 + if (ObjectUtil.isNull(data)) {
  293 + throw new DefaultClientException("产品试样确认单不存在!");
  294 + }
  295 +
  296 + LambdaUpdateWrapper<ProductSampleConfirmationSlip> updateWrapper = Wrappers.lambdaUpdate(ProductSampleConfirmationSlip.class)
  297 + .set(ProductSampleConfirmationSlip::getStatus, StringUtil.isBlank(status) ? null : status)
  298 + .eq(ProductSampleConfirmationSlip::getId, id);
  299 +
  300 + getBaseMapper().update(updateWrapper);
  301 +
  302 + OpLogUtil.setVariable("id", data.getId());
156 303 }
157 304
158 305 @OpLog(type = OtherOpLogType.class, name = "删除产品试样确认单,ID:{}", params = {"#id"})
... ...
... ... @@ -47,6 +47,29 @@ public interface ProductSampleConfirmationSlipService extends BaseMpService<Prod
47 47 void update(UpdateProductSampleConfirmationSlipVo vo);
48 48
49 49 /**
  50 + * 修改不走审核
  51 + *
  52 + * @param vo 参数
  53 + */
  54 + void updateNoFlowInstance(UpdateProductSampleConfirmationSlipVo vo);
  55 +
  56 + /**
  57 + * 更新审核人及意见
  58 + *
  59 + * @param id 主键
  60 + * @param userId 审核人
  61 + * @param nodeCode 节点
  62 + * @param message 审核意见
  63 + * @param review 审核
  64 + */
  65 + void updateExamine(String id, String userId, String nodeCode, String message, String review);
  66 +
  67 + /**
  68 + * 修改审核状态
  69 + */
  70 + void updateStatus(String id, String status);
  71 +
  72 + /**
50 73 * 根据ID删除
51 74 * @param id
52 75 * @return
... ...
... ... @@ -32,6 +32,7 @@
32 32 <result column="production_process" property="productionProcess"/>
33 33 <result column="dept_id" property="deptId"/>
34 34 <result column="dept_name" property="deptName"/>
  35 + <result column="dept_code" property="deptCode"/>
35 36 <result column="region" property="region"/>
36 37 <result column="region_name" property="regionName"/>
37 38 <result column="stock_up_company_id" property="stockUpCompanyId"/>
... ... @@ -86,6 +87,7 @@
86 87 tb.production_process,
87 88 tb.dept_id,
88 89 sd.name AS dept_name,
  90 + sd.code AS dept_code,
89 91 tb.region,
90 92 sd1.name AS region_name,
91 93 tb.stock_up_company_id,
... ...