| | |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.UserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.Format; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @Service("orderDetlService") |
| | |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Value("${erp.switch.ReviewOrderSwitch}") |
| | | private Boolean switchReviewOrderSwitch; |
| | | @Value("${erp.address.URL}") |
| | | private String URL; |
| | | @Value("${erp.address.sServer}") |
| | | private String sServer; |
| | | @Value("${erp.address.sAccID}") |
| | | private String sAccID; |
| | | @Value("${erp.address.sUserID}") |
| | | private String sUserID; |
| | | @Value("${erp.address.sPassword}") |
| | | private String sPassword; |
| | | @Value("${erp.address.inaddressSave}") |
| | | private String inaddressSave; |
| | | @Value("${erp.address.outaddressSave}") |
| | |
| | | OrderRsult.Login login = new OrderRsult.Login(); |
| | | OrderRsult.HeadTable headTable = new OrderRsult.HeadTable(); |
| | | OrderRsult.BodyTable bodyTable = new OrderRsult.BodyTable(); |
| | | login.setSAccID("999"); //账套号 固定 |
| | | login.setSUserID("sys");//U8登陆账号 固定 |
| | | login.setSPassword("123456");//U8登陆密码 固定 |
| | | login.setSServer("10.1.9.20");//U8服务器地址 固定 |
| | | login.setSAccID(sAccID); //账套号 固定 |
| | | login.setSUserID(sUserID);//U8登陆账号 固定 |
| | | login.setSPassword(sPassword);//U8登陆密码 固定 |
| | | login.setSServer(sServer);//U8服务器地址 固定 |
| | | orderRsult.setLogin(login); |
| | | orderRsult.setVerifier("sys");//单据类型 固定 |
| | | orderRsult.setCommandType(sts.equals(1) ? "新增" : "关闭");//操作类型 固定 |
| | |
| | | headTable.setCmaker("sys");//制单人名称 |
| | | headTable.setVt_id("89");//模板号 默认 |
| | | |
| | | headTable.setCiwhcode("");//转入仓库编码 |
| | | headTable.setCowhcode("");//转出仓库编码 |
| | | headTable.setCiwhcode("1");//转入仓库编码 |
| | | headTable.setCowhcode("1");//转出仓库编码 |
| | | headTable.setCordcode("");//出库类别编码 默认 |
| | | headTable.setCirdcode("");//入库类别编码 默认 |
| | | headTable.setCodepcode("");//转出部门编码 |
| | |
| | | bodyTable.setCoutposcode("");//目标货位 |
| | | bodyTable.setItrsid(orderDetl.getMemo());//行主键 |
| | | bodyTable.setEditprop(sts.equals(1) ? "A" : "B");//状态 A 新增 |
| | | User user = userService.selectById(orderDetl.getUpdateBy()); |
| | | headTable.setWms_operator(user == null ? "" : user.getUsername()); // 操作账号名称 |
| | | |
| | | ArrayList<OrderRsult.BodyTable> bodyTables = new ArrayList<>(); |
| | | bodyTables.add(bodyTable); |
| | | orderRsult.setBodyTable(bodyTables); |
| | | |
| | | if (order.getDocType()>10L) { |
| | | ArrayList<OrderRsult.HeadTable> headTables = new ArrayList<>(); |
| | | headTables.add(headTable); |
| | | orderRsult.setHeadTable(headTables); |
| | | |
| | | if (order.getDocType() == 34L) { |
| | | ERPPath=outaddressSave; |
| | | } |
| | | ERPName=order.getDocType$(); |
| | |
| | | System.out.println("response:"+response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | if (jsonObject.getInteger("code").equals(1)) { |
| | | orderDetl.setUnits(qty+orderDetl.getUnits()); |
| | | orderDetl.setStatus(sts); |
| | | orderDetlService.updateById(orderDetl); |
| | | success = true; |
| | | // 一条订单明细完成,上报关闭 |
| | | if (Objects.equals(orderDetl.getAnfme(), orderDetl.getQty())) { |
| | | boolean success2 = false; |
| | | try { |
| | | orderRsult.setCommandType("关闭"); |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(map) |
| | | .setUri(URL) |
| | | .setPath(ERPPath) |
| | | .setJson(JSON.toJSONString(orderRsult)) |
| | | .build() |
| | | .doPost(); |
| | | System.out.println("response:" + response); |
| | | JSONObject jsonObject2 = JSON.parseObject(response); |
| | | |
| | | if (jsonObject2.getInteger("code").equals(1)) { |
| | | success2 = true; |
| | | } else { |
| | | log.error("新增完成调用关闭请求接口失败!!!url:{};request:{};response:{}", URL + "/" + ERPPath, JSON.toJSONString(orderRsult), response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("新增完成调用关闭请求接口异常!!!url:{};request:{};response:{}", URL + "/" + ERPPath, JSON.toJSONString(orderRsult), response); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class); |
| | | apiLogService.save( |
| | | "关闭上报" + ERPName, |
| | | URL + "/" + ERPPath, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(orderRsult), |
| | | response, |
| | | success2 |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", URL+"/"+ERPPath, JSON.toJSONString(orderRsult), response); |
| | | } |