7 changed files with 3 additions and 253 deletions
@ -1,98 +0,0 @@ |
|||
package org.nl.wms.sch.manage; |
|||
|
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.http.HttpRequest; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.SneakyThrows; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.modules.wql.util.SpringContextHolder; |
|||
import org.nl.system.service.param.impl.SysParamServiceImpl; |
|||
import org.redisson.api.RLock; |
|||
import org.redisson.api.RedissonClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
public class AutoQueryUpload { |
|||
|
|||
private final RedissonClient redissonClient; |
|||
|
|||
@SneakyThrows |
|||
public void run() { |
|||
RLock lock = redissonClient.getLock(this.getClass().getName()); |
|||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); |
|||
try { |
|||
if (tryLock){ |
|||
//查询已经处于分配中、分配完但还未回传给MES的销售出库单
|
|||
WQLObject wo = WQLObject.getWQLObject("st_ivt_iostorinv"); |
|||
JSONArray send_rows = wo.query("bill_type = '1001' AND bill_status IN ( '30', '40' ) AND stor_code = 'AC01' AND upload_mes = '0' AND is_delete = '0'").getResultJSONArray(0); |
|||
this.sendInfo(send_rows); |
|||
} |
|||
}finally { |
|||
if (tryLock) { |
|||
lock.unlock(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
void sendInfo(JSONArray send_rows) { |
|||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus"); |
|||
String device_code = "UPLOAD_INFO"; |
|||
JSONObject device_jo = wo.query("device_code = '" + device_code + "'").uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(device_jo.getString("upload_user"))) { |
|||
return; |
|||
} |
|||
String upload_user = device_jo.getString("upload_user"); |
|||
String[] split = upload_user.split(","); |
|||
JSONArray UserList = new JSONArray(); |
|||
if (split.length > 0) { |
|||
for (String s : split) { |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("User", s); |
|||
UserList.add(jo); |
|||
} |
|||
} else { |
|||
return; |
|||
} |
|||
for (int i = 0; i < send_rows.size(); i++) { |
|||
JSONObject row = send_rows.getJSONObject(i); |
|||
String bill_code = row.getString("bill_code"); |
|||
String Message = "出库单号为:" + bill_code + "的单据还未进行质量报告回传,请及时回传!"; |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("SendType", "L"); |
|||
jo.put("Title", "质量报告回传信息"); |
|||
jo.put("WarnType", "string"); |
|||
jo.put("MessageType", "P"); |
|||
jo.put("UserList", UserList); |
|||
jo.put("Message", Message); |
|||
|
|||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("FEISHU_URL").getValue(); |
|||
String api = "/FeiShuNoticesWebApi/CommunalApi"; |
|||
url = url + api; |
|||
try { |
|||
String resultMsg = HttpRequest.post(url) |
|||
.body(String.valueOf(jo)) |
|||
.execute().body(); |
|||
log.info(" " + jo); |
|||
log.info("飞书输出参数为:-------------------" + resultMsg); |
|||
HashMap<String, String> map = new HashMap<>(); |
|||
map.put("is_upload", "1"); |
|||
map.put("upload_time", DateUtil.now()); |
|||
wo.update(map, "device_code = '" + device_code + "'"); |
|||
} catch (Exception e) { |
|||
log.info(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue