Commit 725e51f0b9ca728d01fc179bf4a3976325319054

Authored by yeqianyong
1 parent 9955575d

楚江erp:获取生产工艺历史数据接口开发

... ... @@ -537,6 +537,15 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
537 537 return InvokeResultBuilder.success();
538 538 }
539 539
  540 + @ApiOperation("获取历史生产工艺")
  541 + @GetMapping("/getHistoryProductionProcess")
  542 + public InvokeResult<String> getHistoryProductionProcess(@NotBlank(message = "id不能为空") String id) {
  543 + String productionProcess = purchaseOrderInfoService.getHistoryProductionProcess(id);
  544 + return InvokeResultBuilder.success(productionProcess);
  545 + }
  546 +
  547 +
  548 +
540 549 private File convertExcelToPdf(File excelFile) throws IOException, InterruptedException {
541 550 if (!excelFile.exists()) {
542 551 throw new IllegalArgumentException("Excel 文件不存在: " + excelFile.getAbsolutePath());
... ...
... ... @@ -845,6 +845,101 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
845 845 OpLogUtil.setExtra(vo);
846 846 }
847 847
  848 + @Override
  849 + public String getHistoryProductionProcess(String orderId) {
  850 + if (StringUtils.isBlank(orderId)) {
  851 + return "";
  852 + }
  853 + PurchaseOrderInfo orderInfo = getById(orderId);
  854 + if (orderInfo == null) {
  855 + throw new DefaultClientException("订货单信息不存在!");
  856 + }
  857 + List<PurchaseOrderLine> orderLineList = purchaseOrderLineService.listByOrderIds(Collections.singletonList(orderId), true);
  858 + if (CollectionUtils.isEmpty(orderLineList)) {
  859 + throw new DefaultClientException("订货单物料行数据不存在!");
  860 + }
  861 + String orderingUnit = orderInfo.getOrderingUnit();
  862 + String workshopId = orderInfo.getWorkshopId();
  863 + List<String> industryList = new ArrayList<>();
  864 + List<String> brandList = new ArrayList<>();
  865 + List<String> statusList = new ArrayList<>();
  866 + List<BigDecimal> thicknessList = new ArrayList<>();
  867 + List<BigDecimal> thicknessTolNegList = new ArrayList<>();
  868 + List<BigDecimal> thicknessTolPosList = new ArrayList<>();
  869 + List<BigDecimal> widthList = new ArrayList<>();
  870 + List<BigDecimal> widthTolNegList = new ArrayList<>();
  871 + List<BigDecimal> widthTolPosList = new ArrayList<>();
  872 + for (PurchaseOrderLine orderLine : orderLineList) {
  873 + String industry = orderLine.getIndustry();
  874 + if (StringUtils.isNotBlank(industry) && !industryList.contains(industry)) {
  875 + industryList.add(industry);
  876 + }
  877 + String brand = orderLine.getBrand();
  878 + if (StringUtils.isNotBlank(brand) && !brandList.contains(brand)) {
  879 + brandList.add(brand);
  880 + }
  881 + String status = orderLine.getStatus();
  882 + if (StringUtils.isNotBlank(status) && !statusList.contains(status)) {
  883 + statusList.add(status);
  884 + }
  885 + BigDecimal thickness = orderLine.getThickness();
  886 + if (thickness != null && !isValueExists(thicknessList, thickness)) {
  887 + thicknessList.add(thickness);
  888 + }
  889 + BigDecimal thicknessTolNeg = orderLine.getThicknessTolNeg();
  890 + if (thicknessTolNeg != null && !isValueExists(thicknessTolNegList, thicknessTolNeg)) {
  891 + thicknessTolNegList.add(thicknessTolNeg);
  892 + }
  893 + BigDecimal thicknessTolPos = orderLine.getThicknessTolPos();
  894 + if (thicknessTolPos != null && !isValueExists(thicknessTolPosList, thicknessTolPos)) {
  895 + thicknessTolPosList.add(thicknessTolPos);
  896 + }
  897 + BigDecimal width = orderLine.getWidth();
  898 + if (width != null && !isValueExists(widthList, width)) {
  899 + widthList.add(width);
  900 + }
  901 + BigDecimal widthTolNeg = orderLine.getWidthTolNeg();
  902 + if (widthTolNeg != null && !isValueExists(widthTolNegList, widthTolNeg)) {
  903 + widthTolNegList.add(widthTolNeg);
  904 + }
  905 + BigDecimal widthTolPos = orderLine.getWidthTolPos();
  906 + if (widthTolPos != null && !isValueExists(widthTolPosList, widthTolPos)) {
  907 + widthTolPosList.add(widthTolPos);
  908 + }
  909 + }
  910 + Map<String, Object> params = new HashMap<>();
  911 + params.put("orderId", orderId);
  912 + params.put("orderingUnit", orderingUnit);
  913 + params.put("workshopId", workshopId);
  914 + params.put("industryList", industryList);
  915 + params.put("brandList", brandList);
  916 + params.put("statusList", statusList);
  917 + params.put("thicknessList", thicknessList);
  918 + params.put("thicknessTolNegList", thicknessTolNegList);
  919 + params.put("thicknessTolPosList", thicknessTolPosList);
  920 + params.put("widthList", widthList);
  921 + params.put("widthTolNegList", widthTolNegList);
  922 + params.put("widthTolPosList", widthTolPosList);
  923 +
  924 + List<String> proProcessList = getBaseMapper().queryHisProProcess(params);
  925 + if (CollectionUtils.isEmpty(proProcessList)) {
  926 + return "";
  927 + }
  928 + return String.join("\n\n", proProcessList);
  929 + }
  930 +
  931 +
  932 + /**
  933 + * 判断集合中是否存在一样的数值
  934 + *
  935 + * @param list 数据集
  936 + * @param value 目标值
  937 + * @return boolean
  938 + */
  939 + private boolean isValueExists(List<BigDecimal> list, BigDecimal value) {
  940 + return list.stream().anyMatch(item -> item.compareTo(value) == 0);
  941 + }
  942 +
848 943
849 944 @Override
850 945 public void cleanCacheByKey(Serializable key) {
... ...
... ... @@ -9,6 +9,7 @@ import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
9 9 import org.apache.ibatis.annotations.Param;
10 10
11 11 import java.util.List;
  12 +import java.util.Map;
12 13
13 14 /**
14 15 * <p>
... ... @@ -44,4 +45,12 @@ public interface PurchaseOrderInfoMapper extends BaseMapper<PurchaseOrderInfo> {
44 45 * @return List<PurchaseOrderInfo>
45 46 */
46 47 List<PurchaseOrderInfo> queryByIds(@Param("ids") List<String> ids);
  48 +
  49 + /**
  50 + * 查询历史生产工艺数据
  51 + *
  52 + * @param params 查询参数
  53 + * @return List<String>
  54 + */
  55 + List<String> queryHisProProcess(@Param("params") Map<String, Object> params);
47 56 }
... ...
... ... @@ -161,4 +161,13 @@ public interface PurchaseOrderInfoService extends BaseMpService<PurchaseOrderInf
161 161 * @param vo
162 162 */
163 163 void uploadWarrantyCertificate(UpdatePurchaseOrderInfoVo vo);
  164 +
  165 +
  166 + /**
  167 + * 获取历史生产工艺
  168 + *
  169 + * @param orderId 订货单ID
  170 + * @return String
  171 + */
  172 + String getHistoryProductionProcess(String orderId);
164 173 }
... ...
... ... @@ -288,4 +288,113 @@
288 288 #{id}
289 289 </foreach>
290 290 </select>
  291 +
  292 + <select id="queryHisProProcess" resultType="java.lang.String">
  293 + select o.production_process
  294 + from purchase_order_info o
  295 + inner join tbl_purchase_order_line ol on o.id = ol.purchase_order_id
  296 + where o.ordering_unit = #{params.orderingUnit} and o.workshop_id = #{params.workshopId}
  297 + and o.production_process is not null
  298 + <choose>
  299 + <when test="params.industryList != null and params.industryList.size() > 0">
  300 + and ol.industry in
  301 + <foreach collection="params.industryList" open="(" separator="," close=")" item="item">
  302 + #{item}
  303 + </foreach>
  304 + </when>
  305 + <otherwise>
  306 + and (ol.industry is null or ol.industry = '')
  307 + </otherwise>
  308 + </choose>
  309 + <choose>
  310 + <when test="params.brandList != null and params.brandList.size() > 0">
  311 + and ol.brand in
  312 + <foreach collection="params.brandList" open="(" separator="," close=")" item="item">
  313 + #{item}
  314 + </foreach>
  315 + </when>
  316 + <otherwise>
  317 + and (ol.brand is null or ol.brand = '')
  318 + </otherwise>
  319 + </choose>
  320 + <choose>
  321 + <when test="params.statusList != null and params.statusList.size() > 0">
  322 + and ol.status in
  323 + <foreach collection="params.statusList" open="(" separator="," close=")" item="item">
  324 + #{item}
  325 + </foreach>
  326 + </when>
  327 + <otherwise>
  328 + and (ol.status is null or ol.status = '')
  329 + </otherwise>
  330 + </choose>
  331 + <choose>
  332 + <when test="params.thicknessList != null and params.thicknessList.size() > 0">
  333 + and ol.thickness in
  334 + <foreach collection="params.thicknessList" open="(" separator="," close=")" item="item">
  335 + #{item}
  336 + </foreach>
  337 + </when>
  338 + <otherwise>
  339 + and ol.thickness is null
  340 + </otherwise>
  341 + </choose>
  342 + <choose>
  343 + <when test="params.thicknessTolNegList != null and params.thicknessTolNegList.size() > 0">
  344 + and ol.thickness_tol_neg in
  345 + <foreach collection="params.thicknessTolNegList" open="(" separator="," close=")" item="item">
  346 + #{item}
  347 + </foreach>
  348 + </when>
  349 + <otherwise>
  350 + and ol.thickness_tol_neg is null
  351 + </otherwise>
  352 + </choose>
  353 + <choose>
  354 + <when test="params.thicknessTolPosList != null and params.thicknessTolPosList.size() > 0">
  355 + and ol.thickness_tol_pos in
  356 + <foreach collection="params.thicknessTolPosList" open="(" separator="," close=")" item="item">
  357 + #{item}
  358 + </foreach>
  359 + </when>
  360 + <otherwise>
  361 + and ol.thickness_tol_pos is null
  362 + </otherwise>
  363 + </choose>
  364 + <choose>
  365 + <when test="params.widthList != null and params.widthList.size() > 0">
  366 + and ol.width in
  367 + <foreach collection="params.widthList" open="(" separator="," close=")" item="item">
  368 + #{item}
  369 + </foreach>
  370 + </when>
  371 + <otherwise>
  372 + and ol.width is null
  373 + </otherwise>
  374 + </choose>
  375 + <choose>
  376 + <when test="params.widthTolNegList != null and params.widthTolNegList.size() > 0">
  377 + and ol.width_tol_neg in
  378 + <foreach collection="params.widthTolNegList" open="(" separator="," close=")" item="item">
  379 + #{item}
  380 + </foreach>
  381 + </when>
  382 + <otherwise>
  383 + and ol.width_tol_neg is null
  384 + </otherwise>
  385 + </choose>
  386 + <choose>
  387 + <when test="params.widthTolPosList != null and params.widthTolPosList.size() > 0">
  388 + and ol.width_tol_pos in
  389 + <foreach collection="params.widthTolPosList" open="(" separator="," close=")" item="item">
  390 + #{item}
  391 + </foreach>
  392 + </when>
  393 + <otherwise>
  394 + and ol.width_tol_pos is null
  395 + </otherwise>
  396 + </choose>
  397 + group by o.production_process
  398 + order by max(o.update_time) desc
  399 + </select>
291 400 </mapper>
... ...